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.
38 lines
1.7 KiB
C#
38 lines
1.7 KiB
C#
// Copyright (c) 2026 Duplicati Inc. All rights reserved.
|
|
|
|
using Duplicati.Library.Common.IO;
|
|
using Duplicati.Library.Interface;
|
|
using Google.Apis.Drive.v3.Data;
|
|
using Google.Apis.Drive.v3;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Duplicati.Proprietary.GoogleWorkspace.SourceItems;
|
|
|
|
internal class SharedDriveSourceEntry(string parentPath, string userId, Drive drive, DriveService driveService)
|
|
: MetaEntryBase(Util.AppendDirSeparator(SystemIO.IO_OS.PathCombine(parentPath, drive.Name)), drive.CreatedTimeDateTimeOffset.HasValue ? drive.CreatedTimeDateTimeOffset.Value.UtcDateTime : DateTime.UnixEpoch, DateTime.UnixEpoch)
|
|
{
|
|
public override async IAsyncEnumerable<ISourceProviderEntry> Enumerate([EnumeratorCancellation] CancellationToken cancellationToken)
|
|
{
|
|
if (cancellationToken.IsCancellationRequested) yield break;
|
|
yield return new SharedDriveMetadataSourceEntry(this.Path, drive);
|
|
|
|
if (cancellationToken.IsCancellationRequested) yield break;
|
|
yield return new SharedDrivePermissionsSourceEntry(this.Path, drive, driveService);
|
|
if (cancellationToken.IsCancellationRequested) yield break;
|
|
yield return new DriveFolderSourceEntry(this.Path, userId, "Content", drive.Id, driveService);
|
|
}
|
|
|
|
public override Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
|
|
{
|
|
return Task.FromResult(new Dictionary<string, string?>
|
|
{
|
|
{ "gsuite:v", "1" },
|
|
{ "gsuite:Type", SourceItemType.SharedDrives.ToString() }, // Or specific type?
|
|
{ "gsuite:Name", drive.Name },
|
|
{ "gsuite:Id", drive.Id }
|
|
}
|
|
.Where(kv => !string.IsNullOrEmpty(kv.Value))
|
|
.ToDictionary(kv => kv.Key, kv => kv.Value));
|
|
}
|
|
}
|