2026-02-04 15:44:23 +01:00
|
|
|
// Copyright (c) 2026 Duplicati Inc. All rights reserved.
|
|
|
|
|
|
|
|
|
|
using Duplicati.Library.Common.IO;
|
|
|
|
|
using Duplicati.Library.Interface;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using File = Google.Apis.Drive.v3.Data.File;
|
2026-02-15 22:03:57 +01:00
|
|
|
using Google.Apis.Drive.v3;
|
2026-02-04 15:44:23 +01:00
|
|
|
|
|
|
|
|
namespace Duplicati.Proprietary.GoogleWorkspace.SourceItems;
|
|
|
|
|
|
2026-02-15 22:03:57 +01:00
|
|
|
internal class DriveFileRevisionsSourceEntry(string parentPath, File file, DriveService driveService)
|
2026-02-04 15:44:23 +01:00
|
|
|
: MetaEntryBase(Util.AppendDirSeparator(SystemIO.IO_OS.PathCombine(parentPath, "Revisions")), null, null)
|
|
|
|
|
{
|
|
|
|
|
public override async IAsyncEnumerable<ISourceProviderEntry> Enumerate([EnumeratorCancellation] CancellationToken cancellationToken)
|
|
|
|
|
{
|
2026-02-15 22:03:57 +01:00
|
|
|
var request = driveService.Revisions.List(file.Id);
|
2026-02-04 15:44:23 +01:00
|
|
|
var revisions = await request.ExecuteAsync(cancellationToken);
|
|
|
|
|
|
|
|
|
|
if (revisions.Revisions != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var revision in revisions.Revisions)
|
|
|
|
|
{
|
|
|
|
|
if (cancellationToken.IsCancellationRequested) yield break;
|
2026-02-15 22:03:57 +01:00
|
|
|
yield return new DriveFileRevisionContentSourceEntry(this.Path, file, revision, driveService);
|
2026-02-04 15:44:23 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(new Dictionary<string, string?>
|
|
|
|
|
{
|
|
|
|
|
{ "gsuite:v", "1" },
|
|
|
|
|
{ "gsuite:Type", SourceItemType.DriveFileRevision.ToString() }, // Folder
|
|
|
|
|
{ "gsuite:Name", "Revisions" },
|
2026-02-11 16:23:27 +01:00
|
|
|
{ "gsuite:Id", file.Id + "/revisions" }
|
2026-02-04 15:44:23 +01:00
|
|
|
}
|
|
|
|
|
.Where(kv => !string.IsNullOrEmpty(kv.Value))
|
|
|
|
|
.ToDictionary(kv => kv.Key, kv => kv.Value));
|
|
|
|
|
}
|
|
|
|
|
}
|