feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s

Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
Alby96 authored and Alby96 committed 2026-11-15 18:11:43 +01:00
1 parent 988068ee8e
commit 20d64af4a4
793 files changed
+23882 -2096

No files matched your search

+22 -10
View File
@@ -60,7 +60,7 @@ internal sealed class SyncTransfers(SyncService sync)
: new FramePhotos([]);
var pending = new Queue<Frame>(frames.Where(f => (f.Sha256 is null || (!present.Contains(tombstones.Canonical(f.Sha256)!) && !tombstones.DeletedRemotely(f.Sha256)))
&& adopted.IndexOf(new FramePhoto(f.Sha256, f.Size, f.CapturedAt)) is null));
var progress = new TransferProgress(context, frames.Count, frames.Count - pending.Count);
var progress = new TransferProgress(context, frames.Count, frames.Count - pending.Count, new JobDetail(JobStep.Upload, local.DisplayTitle));
await progress.ReportAsync().ConfigureAwait(false);
var skipped = 0;
// The SHA-256 of each original the index has none for (a folder adopted and not verified), as its upload computes
@@ -135,7 +135,7 @@ internal sealed class SyncTransfers(SyncService sync)
var photos = SyncRules.Photos(frames);
var camera = new SidecarCamera { Make = local.CameraMake, Model = local.CameraModel, Serial = local.CameraSerial };
var decoder = sync.Options.Archive.Decoder;
var progress = new TransferProgress(context, wanted.Count, 0);
var progress = new TransferProgress(context, wanted.Count, 0, new JobDetail(JobStep.Upload, local.DisplayTitle));
await progress.ReportAsync().ConfigureAwait(false);
int sent = 0, unsent = 0;
using var refused = CancellationTokenSource.CreateLinkedTokenSource(ct);
@@ -241,7 +241,8 @@ internal sealed class SyncTransfers(SyncService sync)
var staging = Path.Combine(paths.StagingDirectory, "sync-" + remoteId.ToString("N"));
Directory.CreateDirectory(staging);
var progress = new TransferProgress(context, manifest.Frames.Count, manifest.Frames.Count - wanted.Count);
var progress = new TransferProgress(context, manifest.Frames.Count, manifest.Frames.Count - wanted.Count,
new JobDetail(JobStep.Download, local?.DisplayTitle ?? context.Job.TargetLabel));
await progress.ReportAsync().ConfigureAwait(false);
var created = false;
var rest = wanted;
@@ -457,12 +458,13 @@ internal sealed class SyncTransfers(SyncService sync)
?? throw new InvalidOperationException(Loc.L("Errors.Sync.NotLinked"));
var there = (await remote.GetManifestAsync(link.RemoteId, ct).ConfigureAwait(false)).Renders.Select(r => r.Id).ToHashSet();
var renders = (await db.Renders.ListBySequenceAsync(local.Id, ct).ConfigureAwait(false)).Where(r => !there.Contains(r.Id)).ToList();
var progress = new TransferProgress(context, renders.Count, 0);
var progress = new TransferProgress(context, renders.Count, 0, new JobDetail(JobStep.Upload, local.DisplayTitle), items: false);
await progress.ReportAsync().ConfigureAwait(false);
var gone = 0;
foreach (var render in renders)
{
var file = SyncService.RenderFile(archive, render);
await progress.PartAsync(Path.GetFileName(file)).ConfigureAwait(false);
if (File.Exists(file))
{
var sha = await ChronosClient.HashFileAsync(file, ct).ConfigureAwait(false);
@@ -495,10 +497,11 @@ internal sealed class SyncTransfers(SyncService sync)
var staging = Path.Combine(paths.StagingDirectory, "exports-" + remoteId.ToString("N"));
Directory.CreateDirectory(staging);
var progress = new TransferProgress(context, wanted.Count, 0);
var progress = new TransferProgress(context, wanted.Count, 0, new JobDetail(JobStep.Download, local.DisplayTitle), items: false);
await progress.ReportAsync().ConfigureAwait(false);
foreach (var render in wanted)
{
await progress.PartAsync(render.PresetName).ConfigureAwait(false);
var (part, name, sha) = await FetchRenderAsync(remote, render, staging, ct).ConfigureAwait(false);
var filed = await FileRenderAsync(sync.Archives, db, local, paths, part, name, new Render
{
@@ -630,7 +633,7 @@ internal sealed class SyncTransfers(SyncService sync)
var files = new string?[frames.Count];
var kinds = new string?[frames.Count];
var progress = new TransferProgress(context, frames.Count, 0);
var progress = new TransferProgress(context, frames.Count, 0, new JobDetail(JobStep.Download, context.Job.TargetLabel));
await progress.ReportAsync().ConfigureAwait(false);
await Parallel.ForEachAsync(Enumerable.Range(0, frames.Count), Workers(sync.Options.Downloads, ct), async (i, token) =>
{
@@ -906,8 +909,12 @@ internal sealed class SyncTransfers(SyncService sync)
private static ParallelOptions Workers(int degree, CancellationToken cancellationToken) =>
new() { MaxDegreeOfParallelism = Math.Max(1, degree), CancellationToken = cancellationToken };
/// <summary>Files done out of the total, reported in order from parallel workers.</summary>
private sealed class TransferProgress(JobContext context, long total, long done)
/// <summary>
/// Files done out of the total, reported in order from parallel workers, with what moves (<paramref name="detail"/>: up or
/// down, the sequence): photo x of y of the transfer when <paramref name="items"/>, else the file being moved, video n of m
/// (<see cref="PartAsync"/>).
/// </summary>
private sealed class TransferProgress(JobContext context, long total, long done, JobDetail detail, bool items = true)
{
private readonly SemaphoreSlim _gate = new(1, 1);
@@ -917,7 +924,8 @@ internal sealed class SyncTransfers(SyncService sync)
try
{
done++;
await context.ReportAsync(done, total).ConfigureAwait(false);
if (items) await context.ReportItemAsync(done, total, done, total).ConfigureAwait(false);
else await context.ReportAsync(done, total).ConfigureAwait(false);
}
finally
{
@@ -927,7 +935,11 @@ internal sealed class SyncTransfers(SyncService sync)
public long Done => done;
public ValueTask ReportAsync() => context.ReportAsync(done, total);
public ValueTask ReportAsync() => context.ReportAsync(done, total, items ? detail with { ItemDone = done, ItemTotal = total } : detail);
/// <summary>The next video starts moving: its file name, video n of m.</summary>
public ValueTask PartAsync(string? file) =>
context.ReportAsync(done, total, detail with { Item = file, Part = (int)Math.Min(done + 1, total), Parts = (int)total, PartUnit = JobPartUnit.Render });
}
}