Reworked the use of scopes.
Instead of requesting all scopes up front, each sub-section of the backup/restore will request the permissions that are relevant for the operation. The effect is that it is not required to grant all permissions to get a backup running. If permissions are failing, that part of the backup will generate warnings for items that are excluded.
This commit is contained in:
@@ -3,17 +3,17 @@
|
||||
using Duplicati.Library.Common.IO;
|
||||
using Google.Apis.Drive.v3.Data;
|
||||
using File = Google.Apis.Drive.v3.Data.File;
|
||||
using Google.Apis.Drive.v3;
|
||||
|
||||
namespace Duplicati.Proprietary.GoogleWorkspace.SourceItems;
|
||||
|
||||
internal class DriveFileRevisionContentSourceEntry(SourceProvider provider, string parentPath, File file, Revision revision)
|
||||
internal class DriveFileRevisionContentSourceEntry(string parentPath, File file, Revision revision, DriveService driveService)
|
||||
: StreamResourceEntryBase(SystemIO.IO_OS.PathCombine(parentPath, revision.Id), revision.ModifiedTimeDateTimeOffset.HasValue ? revision.ModifiedTimeDateTimeOffset.Value.UtcDateTime : DateTime.UnixEpoch, revision.ModifiedTimeDateTimeOffset.HasValue ? revision.ModifiedTimeDateTimeOffset.Value.UtcDateTime : DateTime.UnixEpoch)
|
||||
{
|
||||
public override long Size => revision.Size ?? -1;
|
||||
|
||||
public override async Task<Stream> OpenRead(CancellationToken cancellationToken)
|
||||
{
|
||||
var service = provider.ApiHelper.GetDriveService();
|
||||
var url = $"https://www.googleapis.com/drive/v3/files/{file.Id}/revisions/{revision.Id}?alt=media";
|
||||
|
||||
if (GoogleMimeTypes.IsGoogleDoc(file.MimeType))
|
||||
@@ -37,7 +37,7 @@ internal class DriveFileRevisionContentSourceEntry(SourceProvider provider, stri
|
||||
}
|
||||
}
|
||||
|
||||
var response = await service.HttpClient.GetAsync(url, cancellationToken);
|
||||
var response = await driveService.HttpClient.GetAsync(url, cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
|
||||
Reference in New Issue
Block a user