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

@@ -36,6 +36,12 @@ public sealed record WorkspaceTrashPlan(string Folder, IReadOnlyList<WorkspaceTr
{
/// <summary>Nothing to erase: Empty… is disabled.</summary>
public bool IsEmpty => Items.Count == 0;
/// <summary>
/// The trash of each home the plan lists (owner review 5, separate homes: <c>local\</c> and each <c>servers\&lt;id&gt;\</c>
/// keep their own), each with its own fingerprint; emptying erases each one only while all of them still match.
/// </summary>
public IReadOnlyList<WorkspaceTrashListing> Listings { get; init; } = [];
}
/// <summary>What emptying the workspace's trash erased.</summary>
@@ -63,21 +69,28 @@ public sealed partial class WorkspaceHost
var root = Root;
if (!Directory.Exists(root)) return WorkspaceUsage.None;
var media = 0L;
foreach (var folder in Directory.EnumerateDirectories(root).Where(d => Guid.TryParseExact(Path.GetFileName(d), "N", out _)))
foreach (var store in Homes.All())
{
cancellationToken.ThrowIfCancellationRequested();
media += WorkspaceCleaner.Measure(Path.Combine(folder, WorkspaceProject.MediaFolder)).Bytes;
if (!Directory.Exists(store.Root)) continue;
foreach (var folder in Directory.EnumerateDirectories(store.Root).Where(d => Guid.TryParseExact(Path.GetFileName(d), "N", out _)))
{
cancellationToken.ThrowIfCancellationRequested();
media += WorkspaceCleaner.Measure(Path.Combine(folder, WorkspaceProject.MediaFolder)).Bytes;
}
}
var trash = WorkspaceTrash.List(root, cancellationToken);
return new WorkspaceUsage(media, WorkspaceCleaner.Measure(root).Bytes, trash.Bytes, trash.Entries.Count);
var trash = Homes.Trash(cancellationToken);
return new WorkspaceUsage(media, WorkspaceCleaner.Measure(root).Bytes, trash.Sum(t => t.Bytes), trash.Sum(t => t.Entries.Count));
}, cancellationToken);
/// <summary>The plan of emptying the workspace's trash (<see cref="WorkspaceTrashPlan"/>); nothing is erased.</summary>
/// <summary>The plan of emptying the trash of every home of the workspace (<see cref="WorkspaceTrashPlan"/>); nothing is erased.</summary>
public Task<WorkspaceTrashPlan> PlanTrashAsync(CancellationToken cancellationToken = default) => Task.Run(() =>
{
var listing = WorkspaceTrash.List(Root, cancellationToken);
return new WorkspaceTrashPlan(listing.Folder, [.. listing.Entries.Select(e => new WorkspaceTrashItem(e.Name, e.Bytes, e.Files, e.Trashed))], listing.Bytes,
listing.Fingerprint);
var listings = Homes.Trash(cancellationToken);
var folder = listings.Count == 1 ? listings[0].Folder : WorkspaceTrash.FolderOf(Root);
var fingerprint = string.Join('|', listings.Select(l => l.Folder + "=" + l.Fingerprint));
return new WorkspaceTrashPlan(folder, [.. listings.SelectMany(l => l.Entries).Select(e => new WorkspaceTrashItem(e.Name, e.Bytes, e.Files, e.Trashed))
.OrderBy(i => i.Trashed)], listings.Sum(l => l.Bytes), fingerprint)
{ Listings = listings };
}, cancellationToken);
/// <summary>
@@ -92,11 +105,25 @@ public sealed partial class WorkspaceHost
return Task.Run(() =>
{
EnsureNotMoving();
var listing = new WorkspaceTrashListing(plan.Folder, [.. plan.Items.Select(i => new WorkspaceTrashEntry(i.Name, i.Bytes, i.Files, i.Trashed))], plan.Bytes,
plan.Fingerprint);
IReadOnlyList<WorkspaceTrashListing> listings = plan.Listings.Count > 0 ? plan.Listings
: [new WorkspaceTrashListing(plan.Folder, [.. plan.Items.Select(i => new WorkspaceTrashEntry(i.Name, i.Bytes, i.Files, i.Trashed))], plan.Bytes,
plan.Fingerprint)];
try
{
var (items, bytes) = WorkspaceTrash.Empty(Root, listing, cancellationToken);
// Every trash is checked before any is emptied: a plan is erased whole or not at all.
foreach (var listing in listings)
{
var now = WorkspaceTrash.List(Path.GetDirectoryName(listing.Folder)!, cancellationToken);
if (!string.Equals(now.Fingerprint, listing.Fingerprint, StringComparison.Ordinal))
throw new WorkspaceTrashChangedException($"The trash {now.Folder} changed after it was listed.");
}
var (items, bytes) = (0, 0L);
foreach (var listing in listings.Where(l => !l.IsEmpty))
{
var (erased, freed) = WorkspaceTrash.Empty(Path.GetDirectoryName(listing.Folder)!, listing, cancellationToken);
items += erased;
bytes += freed;
}
return new WorkspaceTrashResult(items, bytes);
}
catch (WorkspaceTrashChangedException ex)
@@ -130,7 +157,7 @@ public sealed partial class WorkspaceHost
await _cleaning.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
var cleaner = new WorkspaceCleaner(Sync, db, HomeOf) { LockWait = LockWait };
var cleaner = new WorkspaceCleaner(AllSyncs(), db, HomeOf) { LockWait = LockWait };
return await Task.Run(() => cleaner.CleanAsync(options, cancellationToken), cancellationToken).ConfigureAwait(false);
}
finally
@@ -147,10 +174,7 @@ public sealed partial class WorkspaceHost
{
ArgumentNullException.ThrowIfNull(job);
if (job is not { Kind: JobKind.WorkspaceCopy, State: JobState.Done } || _settings.WorkspaceSizeLimitGb <= 0) return;
if (WorkspaceJobs.CopyParameters(job) is not { } copied
|| !string.Equals(Path.TrimEndingDirectorySeparator(Path.GetFullPath(copied.WorkspaceRoot)), Path.TrimEndingDirectorySeparator(Path.GetFullPath(Root)),
StringComparison.OrdinalIgnoreCase))
return;
if (WorkspaceJobs.CopyParameters(job) is not { } copied || !IsUnderRoot(copied.WorkspaceRoot)) return;
_ = Task.Run(async () =>
{
try
@@ -165,6 +189,16 @@ public sealed partial class WorkspaceHost
});
}
/// <summary>The folder is the workspace's own or one of its homes (<c>local\</c>, <c>servers\&lt;id&gt;\</c>).</summary>
private bool IsUnderRoot(string folder)
{
if (string.IsNullOrWhiteSpace(folder)) return false;
var root = Path.TrimEndingDirectorySeparator(Path.GetFullPath(Root));
var full = Path.TrimEndingDirectorySeparator(Path.GetFullPath(folder));
return string.Equals(full, root, StringComparison.OrdinalIgnoreCase)
|| full.StartsWith(root + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase);
}
/// <summary>When each project was opened last, as Settings hold it now (written on the UI thread: copied until a copy reads whole).</summary>
private IReadOnlyDictionary<Guid, DateTimeOffset> OpenedSnapshot()
{
@@ -331,7 +365,7 @@ public sealed partial class WorkspaceHost
if (WorkspaceJobs.SendParameters(pending)?.ProjectId == project.ProjectId) return;
}
var title = project.ReadBundle().Sequence.Title ?? string.Empty;
var job = await engine.EnqueueAsync(WorkspaceJobs.Send(workspace.Home.SequenceId, title, Store.Root, project.ProjectId, [], workspace.Home.Server),
var job = await engine.EnqueueAsync(WorkspaceJobs.Send(workspace.Home.SequenceId, title, project.Store.Root, project.ProjectId, [], workspace.Home.Server),
cancellationToken: cancellationToken).ConfigureAwait(false);
Log.Info("workspace", $"The renders of project {project.ProjectId} not sent yet are queued to be sent (job {job.Id})");
}