feat: owner review 2 phase 4a: Reorganize sequences after import (#12)
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
- Reorganize… on the web panel and the desktop: folder, file and title templates applied to existing sequences, with a dry run and an explicit Apply that runs as a job. - One naming rule (FrameNaming) for import, upload and Reorganize. - Crash-safe plan and file journals, held plans, stale-plan refusal; exports move with their folder. - Writers refuse a folder another program moved or gave to another sequence. - Server: POST /api/v1/archive/reorganize with a bounded plan cache; template rules. - Phase 3 docs and translations merged; strings in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
1 parent
9aa818ed47
commit
7e4a3b481d
416 files changed
+15304
-1572
No files matched your search
@@ -15,6 +15,7 @@ using Chronos.Core.Model;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Data.Processing;
|
||||
using Chronos.Data.Repositories;
|
||||
using Chronos.Ui.Mvvm;
|
||||
@@ -24,8 +25,8 @@ namespace Chronos.App.Sections;
|
||||
|
||||
/// <summary>
|
||||
/// Archive manager (BRIEF §12.5, Archive.html): the archive's tree (years, sequences) with its availability, its
|
||||
/// figures and charts, mass operations on the selected and filtered set (analyse, proxies, thumbnails, verify, rename,
|
||||
/// move, retag, CSV, delete into the trash), and the operations on the whole archive as jobs (scan, rebuild with its
|
||||
/// figures and charts, mass operations on the selected and filtered set (analyse, proxies, thumbnails, verify,
|
||||
/// reorganize, retag, CSV, delete into the trash), and the operations on the whole archive as jobs (scan, rebuild with its
|
||||
/// dialog, verify, maintenance), the trash, plus the maintenance view: index health, duplicates and orphans with safe
|
||||
/// fixes, recent runs. The
|
||||
/// tree selection is only ever changed by the user: reloads and expanding keep it.
|
||||
@@ -60,6 +61,10 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
private bool _jobEvents;
|
||||
private string _lastScanText = string.Empty;
|
||||
private ArchiveDialogViewModel? _dialog;
|
||||
|
||||
/// <summary>A Reorganize the Settings toast asked for while a dialog was open: it opens once that one closes.</summary>
|
||||
private (Core.Model.Archive Archive, ReorganizeParts Parts)? _waitingReorganize;
|
||||
|
||||
private IReadOnlyList<ArchiveTile> _tiles = [];
|
||||
private IReadOnlyList<ChartRow> _months = [];
|
||||
private IReadOnlyList<ChartItem> _storage = [];
|
||||
@@ -104,8 +109,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
ProxiesSetCommand = new AsyncRelayCommand(() => QueueSetAsync(ids => ArchiveJobs.Proxies(ids, SetLabel()), Set()), HasSet);
|
||||
ThumbnailsSetCommand = new AsyncRelayCommand(() => QueueSetAsync(ids => ArchiveJobs.Thumbnails(ids, SetLabel()), Set()), HasSet);
|
||||
VerifySetCommand = new AsyncRelayCommand(() => QueueSetAsync(ids => ArchiveJobs.Verify(_archive!, ids), Set()), HasSet);
|
||||
RenameSetCommand = new AsyncRelayCommand(() => OpenRenameDialogAsync(RenameMode.Titles), () => HasSet() && IsOnline());
|
||||
MoveSetCommand = new AsyncRelayCommand(() => OpenRenameDialogAsync(RenameMode.Folders), () => HasSet() && IsOnline());
|
||||
ReorganizeSetCommand = new AsyncRelayCommand(() => OpenReorganizeDialogAsync(), () => HasSet() && IsOnline());
|
||||
RetagSetCommand = new RelayCommand(OpenRetag, () => HasSet() && IsOnline());
|
||||
ExportSetCommand = new AsyncRelayCommand(ExportAsync, HasSet);
|
||||
DeleteSetCommand = new AsyncRelayCommand(DeleteSetAsync, () => HasSet() && IsOnline());
|
||||
@@ -174,8 +178,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
public string ThumbnailsSetToolTip => WhenSet("Tooltips.Archive.SetThumbnails");
|
||||
public string VerifySetToolTip => WhenSet("Tooltips.Archive.SetVerify");
|
||||
public string ExportSetToolTip => WhenSet("Tooltips.Archive.SetExport");
|
||||
public string RenameSetToolTip => WhenSet("Tooltips.Archive.SetRename", needsOnline: true);
|
||||
public string MoveSetToolTip => WhenSet("Tooltips.Archive.SetMove", needsOnline: true);
|
||||
public string ReorganizeSetToolTip => WhenSet("Tooltips.Archive.SetReorganize", needsOnline: true);
|
||||
public string RetagSetToolTip => WhenSet("Tooltips.Archive.SetRetag", needsOnline: true);
|
||||
public string DeleteSetToolTip => WhenSet("Tooltips.Archive.SetDelete", needsOnline: true);
|
||||
|
||||
@@ -275,8 +278,10 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
public ICommand ProxiesSetCommand { get; }
|
||||
public ICommand ThumbnailsSetCommand { get; }
|
||||
public ICommand VerifySetCommand { get; }
|
||||
public ICommand RenameSetCommand { get; }
|
||||
public ICommand MoveSetCommand { get; }
|
||||
|
||||
/// <summary>Reorganize…: the set's folders, file names and titles from templates, a dry run first, then a job.</summary>
|
||||
public ICommand ReorganizeSetCommand { get; }
|
||||
|
||||
public ICommand RetagSetCommand { get; }
|
||||
public ICommand ExportSetCommand { get; }
|
||||
|
||||
@@ -359,7 +364,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
|
||||
// ---------------- Dialogs ----------------
|
||||
|
||||
/// <summary>The open in-window dialog (rebuild, rename, retag, trash); null when none.</summary>
|
||||
/// <summary>The open in-window dialog (rebuild, reorganize, retag, delete, trash); null when none.</summary>
|
||||
public ArchiveDialogViewModel? Dialog
|
||||
{
|
||||
get => _dialog;
|
||||
@@ -515,6 +520,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
_reloadDelay.Stop();
|
||||
_search?.Cancel();
|
||||
if (_jobEvents && Services.Jobs is { } jobs) jobs.JobChanged -= OnJobChanged;
|
||||
_waitingReorganize = null;
|
||||
_dialog?.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
@@ -627,8 +633,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
OnPropertyChanged(nameof(ThumbnailsSetToolTip));
|
||||
OnPropertyChanged(nameof(VerifySetToolTip));
|
||||
OnPropertyChanged(nameof(ExportSetToolTip));
|
||||
OnPropertyChanged(nameof(RenameSetToolTip));
|
||||
OnPropertyChanged(nameof(MoveSetToolTip));
|
||||
OnPropertyChanged(nameof(ReorganizeSetToolTip));
|
||||
OnPropertyChanged(nameof(RetagSetToolTip));
|
||||
OnPropertyChanged(nameof(DeleteSetToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
@@ -675,7 +680,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
{
|
||||
if (job.State is not (JobState.Done or JobState.Failed)) return;
|
||||
if (job.Kind is not (JobKind.Scan or JobKind.Rebuild or JobKind.Verify or JobKind.Maintenance or JobKind.Import or JobKind.Proxies or JobKind.Thumbs
|
||||
or JobKind.LightAnalyse or JobKind.DeepAnalyse)) return;
|
||||
or JobKind.LightAnalyse or JobKind.DeepAnalyse or JobKind.Move)) return;
|
||||
System.Windows.Application.Current?.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (_archive is not { } archive || !job.TargetIds.Any(id => id == archive.Id || _sequenceIds.Contains(id))) return;
|
||||
@@ -758,15 +763,69 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
Shell.Notify(Loc.L("Library.Queued", JobText.Kind(kind), label), actionText: Loc.L("Shell.Nav.Jobs"), actionToolTip: Loc.L("Tooltips.Nav.Jobs"),
|
||||
action: () => Shell.Navigate(SectionKey.Jobs));
|
||||
|
||||
/// <summary>Opens Rename or Move on the set and waits for its dry run.</summary>
|
||||
public async Task OpenRenameDialogAsync(RenameMode mode)
|
||||
/// <summary>Opens Reorganize on the set, the archive's layout (folders and file names) switched on, and waits for its dry run.</summary>
|
||||
public async Task OpenReorganizeDialogAsync()
|
||||
{
|
||||
if (Services.Archives is not { } archives || _archive is not { } archive) return;
|
||||
var dialog = new RenameDialogViewModel(mode, archives, archive, Set(), Applied, CloseDialog);
|
||||
if (Services.Archives is not { } archives || Services.Engine is not { } engine || _archive is not { } shown) return;
|
||||
IReadOnlyList<Guid> set = [.. Set().Select(s => s.Id)];
|
||||
// The templates as they are now: Settings › Archive may have changed them since this screen read the archive.
|
||||
var archive = await FreshAsync(shown);
|
||||
var dialog = new ReorganizeDialogViewModel(archives, archive, set, ReorganizePlans.Layout, r => EnqueueAsync(engine, r), CloseDialog);
|
||||
OpenDialog(dialog);
|
||||
await dialog.PlanAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens Reorganize on every sequence of <paramref name="archive"/> (Settings › Archive offers it after its templates
|
||||
/// changed), with <paramref name="parts"/> switched on; the screen shows that archive. The toast is reached from
|
||||
/// another screen, so a dialog may be open here, a Delete moving sequences say: it is never replaced nor its archive
|
||||
/// switched under it; Reorganize waits, says so, and opens once that dialog closes.
|
||||
/// </summary>
|
||||
public async Task OpenReorganizeAllAsync(Core.Model.Archive archive, ReorganizeParts parts)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(archive);
|
||||
if (_dialog is not null)
|
||||
{
|
||||
_waitingReorganize = _waitingReorganize is { } waiting && waiting.Archive.Id == archive.Id ? (archive, waiting.Parts | parts) : (archive, parts);
|
||||
Shell.Notify(Loc.L("Archive.Reorganize.Waiting"));
|
||||
return;
|
||||
}
|
||||
if (Services.Archives is not { } archives || Services.Engine is not { } engine) return;
|
||||
if (_archive != archive) SelectedArchive = archive;
|
||||
var dialog = new ReorganizeDialogViewModel(archives, archive, null, parts, r => EnqueueAsync(engine, r), CloseDialog);
|
||||
OpenDialog(dialog);
|
||||
await dialog.PlanAsync();
|
||||
}
|
||||
|
||||
/// <summary>The Reorganize that waited for the dialog that just closed, with the archive's templates as they are now.</summary>
|
||||
private async Task OpenWaitingReorganizeAsync()
|
||||
{
|
||||
if (_waitingReorganize is not { } waiting) return;
|
||||
_waitingReorganize = null;
|
||||
await OpenReorganizeAllAsync(await FreshAsync(waiting.Archive), waiting.Parts);
|
||||
}
|
||||
|
||||
/// <summary>The archive's record as the index holds it now; <paramref name="archive"/> when it cannot be read.</summary>
|
||||
private async Task<Core.Model.Archive> FreshAsync(Core.Model.Archive archive)
|
||||
{
|
||||
if (Services.Database is not { } db) return archive;
|
||||
try
|
||||
{
|
||||
return await db.Archives.GetAsync(archive.Id) ?? archive;
|
||||
}
|
||||
catch (DatabaseException ex)
|
||||
{
|
||||
Log.Warning("archive", "The archive's templates were not read again", ex);
|
||||
return archive;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task EnqueueAsync(JobEngine engine, ArchiveJobRequest request)
|
||||
{
|
||||
await engine.EnqueueAsync(request);
|
||||
Queued(request.Kind, request.Label ?? SetLabel());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete… on the set: the dry run, the typed confirmation and the move into the trash, in the in-window dialog the
|
||||
/// Library shares, which says how far it is and stops on Cancel. True when something left the archive.
|
||||
@@ -815,12 +874,16 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
await Shell.Library.RefreshAsync();
|
||||
}
|
||||
|
||||
/// <summary>Closes <paramref name="dialog"/> if it is still the open one (an apply that finishes late closes nothing else).</summary>
|
||||
/// <summary>
|
||||
/// Closes <paramref name="dialog"/> if it is still the open one (an apply that finishes late closes nothing else); a
|
||||
/// Reorganize asked for meanwhile opens then.
|
||||
/// </summary>
|
||||
private void CloseDialog(ArchiveDialogViewModel dialog)
|
||||
{
|
||||
if (!ReferenceEquals(_dialog, dialog)) return;
|
||||
dialog.Dispose();
|
||||
Dialog = null;
|
||||
_ = OpenWaitingReorganizeAsync();
|
||||
}
|
||||
|
||||
private async Task AdoptAsync()
|
||||
|
||||
Reference in new issue
Block a user