diff --git a/i18n/en/Errors.resx b/i18n/en/Errors.resx index 5eec3ce5..e29c29ca 100644 --- a/i18n/en/Errors.resx +++ b/i18n/en/Errors.resx @@ -114,4 +114,5 @@ The workspace changed after its plan was shown; nothing was moved: plan the move again. {0} did not match its source after it was copied; the workspace stays where it was. The target drive needs {0} GB more for the workspace. + {0} is an image sequence: a server takes one file per render, so it stays in the workspace. diff --git a/i18n/it/Errors.it.resx b/i18n/it/Errors.it.resx index 290ef057..831798ef 100644 --- a/i18n/it/Errors.it.resx +++ b/i18n/it/Errors.it.resx @@ -114,4 +114,5 @@ Lo spazio di lavoro è cambiato dopo che il piano è stato mostrato; non è stato spostato nulla: pianifica di nuovo. {0} non corrispondeva alla sua origine dopo la copia; lo spazio di lavoro resta dov'era. Al disco di destinazione servono altri {0} GB per lo spazio di lavoro. + {0} è una sequenza di immagini: un server accetta un file per render, quindi resta nello spazio di lavoro. diff --git a/src/Chronos.App/Sections/SettingsViewModel.cs b/src/Chronos.App/Sections/SettingsViewModel.cs index 1035379d..cb6899a6 100644 --- a/src/Chronos.App/Sections/SettingsViewModel.cs +++ b/src/Chronos.App/Sections/SettingsViewModel.cs @@ -765,6 +765,14 @@ public sealed class SettingsViewModel : SectionViewModel WorkspaceRows.Refresh(); } + /// A move of the workspace folder ended (any thread): the page shows the folder in use, what it takes, and Move… and Change… again. + private void OnWorkspaceMoveEnded() => System.Windows.Application.Current?.Dispatcher.BeginInvoke(() => + { + WorkspaceRows.Refresh(); + CommandManager.InvalidateRequerySuggested(); + if (_page == SettingsPage.Workspace) _ = WorkspaceRows.MeasureAsync(); + }); + // ---------------- Server ---------------- public EditableField DefaultServer { get; } @@ -875,6 +883,7 @@ public sealed class SettingsViewModel : SectionViewModel } LoadCertificates(); Shell.Services.Server.PropertyChanged += OnServerChanged; + Shell.Services.Workspace.MoveEnded += OnWorkspaceMoveEnded; if (System.Windows.Application.Current is { } app) _interfacePriority = new InterfacePriority(app, () => _s.BackgroundPriority); _ = LoadArchiveAsync(); switch (Shell.Services.StagedRestore) @@ -908,6 +917,7 @@ public sealed class SettingsViewModel : SectionViewModel { Loc.CultureChanged -= OnCultureChanged; Shell.Services.Server.PropertyChanged -= OnServerChanged; + Shell.Services.Workspace.MoveEnded -= OnWorkspaceMoveEnded; _selfTest?.Cancel(); _interfacePriority?.Dispose(); base.Dispose(); diff --git a/src/Chronos.App/Workspace/WorkspaceHost.Move.cs b/src/Chronos.App/Workspace/WorkspaceHost.Move.cs index f1250666..1f7cdbf2 100644 --- a/src/Chronos.App/Workspace/WorkspaceHost.Move.cs +++ b/src/Chronos.App/Workspace/WorkspaceHost.Move.cs @@ -74,6 +74,12 @@ public sealed partial class WorkspaceHost } } + /// + /// A move of the workspace folder followed here ended, however it ended (any thread): the folder in use may have changed, + /// and the workspace is no longer held for it (Settings › Workspace shows the folder and what it takes again). + /// + public event Action? MoveEnded; + /// /// A move stopped before it ended: the folder in use holds its journal and no move job waits, runs or is paused. Null /// when there is none (a move under way is no move to take up). A move job waiting at start is followed from now on, @@ -230,8 +236,10 @@ public sealed partial class WorkspaceHost if (job.Kind != JobKind.WorkspaceMove || job.State is not (JobState.Done or JobState.Failed or JobState.Cancelled)) return; lock (_gate) { - if (_moveJob == job.Id) _moveJob = Guid.Empty; + if (_moveJob != job.Id) return; + _moveJob = Guid.Empty; } + MoveEnded?.Invoke(); } /// A project as the move's plan lists it, read from the workspace alone (its versions not sent, its ledger, its changes). @@ -244,7 +252,7 @@ public sealed partial class WorkspaceHost try { var status = await Sync.StatusAsync(folder.ProjectId, null, cancellationToken).ConfigureAwait(false); - var renders = UnsentRenders(project); + var renders = WorkspaceCleaner.UnsentRenders(project); return new WorkspaceMoveProject(folder.ProjectId, entry.Name, folder.Files, folder.Bytes, status.Ahead + status.Damaged + renders > 0 || status.Conflict is not null, status.Modified && !status.ReadOnly); } @@ -253,18 +261,5 @@ public sealed partial class WorkspaceHost Log.Info("workspace", $"Where project {folder.ProjectId} stands could not be read for the move's plan: {ex.Message}"); return new WorkspaceMoveProject(folder.ProjectId, entry.Name, folder.Files, folder.Bytes, true, false); } - - static int UnsentRenders(WorkspaceProject project) - { - try - { - return project.ReadRenders().Unsent.Count; - } - catch (InvalidDataException) - { - // A ledger this Chronos cannot read: what it lists is not known to be at the home. - return 1; - } - } } } diff --git a/src/Chronos.App/Workspace/WorkspaceHost.cs b/src/Chronos.App/Workspace/WorkspaceHost.cs index 1ec4308d..875904f8 100644 --- a/src/Chronos.App/Workspace/WorkspaceHost.cs +++ b/src/Chronos.App/Workspace/WorkspaceHost.cs @@ -707,6 +707,7 @@ public sealed partial class WorkspaceHost /// The home cannot be reached now: the name stays. public Task RenameAsync(Guid projectId, string name, CancellationToken cancellationToken = default) => Task.Run(async () => { + EnsureNotMoving(); var project = Existing(projectId); var renamed = await HomeOfProject(projectId).RenameAsync(projectId, name, cancellationToken).ConfigureAwait(false); using (await project.LockAsync(LockWait, cancellationToken).ConfigureAwait(false)) @@ -732,6 +733,7 @@ public sealed partial class WorkspaceHost { var (sequenceId, removed) = await Task.Run(async () => { + EnsureNotMoving(); var project = Existing(projectId); var workspace = project.ReadBundle().Workspace!; if (workspace.IsMain) throw new ProjectException(ProjectError.MainCannotBeDeleted, "The Main project cannot be deleted."); @@ -816,6 +818,8 @@ public sealed partial class WorkspaceHost { var sequenceId = await Task.Run(async () => { + // A move takes every project folder as it stands: none goes to the trash meanwhile. + EnsureNotMoving(); var project = Existing(projectId); var entry = await EntryOrUnreadableAsync(project, cancellationToken).ConfigureAwait(false); if (entry.Newer) throw Unreadable(entry); diff --git a/src/Chronos.App/Workspace/WorkspaceTrashDialog.cs b/src/Chronos.App/Workspace/WorkspaceTrashDialog.cs deleted file mode 100644 index ab30a89c..00000000 --- a/src/Chronos.App/Workspace/WorkspaceTrashDialog.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Globalization; -using System.Windows.Input; -using Chronos.App.Archiving; -using Chronos.App.Infrastructure; -using Chronos.Core.Diagnostics; -using Chronos.Core.Localization; -using Chronos.Ui.Mvvm; - -namespace Chronos.App.Workspace; - -/// One entry of the workspace's trash as Empty… lists it: "name · 1.2 GB · 04/11/2026". -public sealed class WorkspaceTrashRowViewModel(WorkspaceTrashItem item) -{ - public WorkspaceTrashItem Item { get; } = item; - - public string Text => Loc.L("Settings.Workspace.TrashPlan.Item", Item.Name, Formatting.Bytes(Item.Bytes), - Formatting.Date(Item.Trashed) + " " + Formatting.TimeOfDay(Item.Trashed)); -} - -/// -/// Settings › Workspace › Trash › Empty… (phase 5c): the plan (every entry of the workspace's trash, their number and size, -/// ), then Erase for good, which enables only once the user typed the number of entries; the -/// emptying erases exactly the entries listed, and is refused when the trash changed since (the plan is shown again then). -/// Keep closes it, erasing nothing. -/// -public sealed class WorkspaceTrashDialogViewModel : ArchiveDialogViewModel -{ - private readonly Func> _empty; - private readonly Action? _emptied; - private string _typed = string.Empty; - - /// Erases the plan's entries (). - /// Told what was erased, once the dialog closes on it (the page measures the workspace again). - public WorkspaceTrashDialogViewModel(WorkspaceTrashPlan plan, Func> empty, Action? emptied, - Action close) - : base(close) - { - ArgumentNullException.ThrowIfNull(plan); - ArgumentNullException.ThrowIfNull(empty); - Plan = plan; - _empty = empty; - _emptied = emptied; - Rows = [.. plan.Items.Select(i => new WorkspaceTrashRowViewModel(i))]; - EraseCommand = new AsyncRelayCommand(EraseAsync, () => CanErase); - } - - public WorkspaceTrashPlan Plan { get; } - - public IReadOnlyList Rows { get; } - - public string Heading => Loc.L("Settings.Workspace.TrashPlan.Title"); - - public string Message => Loc.L("Settings.Workspace.TrashPlan.Message"); - - /// "Entries: 3". - public string ItemsText => Loc.L("Settings.Workspace.TrashPlan.Items", Formatting.Count(Plan.Items.Count)); - - /// "Size: 1.2 GB". - public string SizeText => Loc.L("Settings.Workspace.TrashPlan.Size", Formatting.Bytes(Plan.Bytes)); - - /// What the user types to confirm: the number of entries, in plain digits. - public string Confirmation => Plan.Items.Count.ToString(CultureInfo.InvariantCulture); - - /// "Type the number of entries, 3, to confirm". - public string TypedPrompt => Loc.L("Settings.Workspace.TrashPlan.Type", Confirmation); - - /// What the user typed; Erase for good enables once it is . - public string Typed - { - get => _typed; - set - { - if (!Set(ref _typed, value ?? string.Empty)) return; - OnPropertyChanged(nameof(CanErase)); - CommandManager.InvalidateRequerySuggested(); - } - } - - /// The trash holds something, the number typed matches, and nothing runs. - public bool CanErase => !IsBusy && !Plan.IsEmpty && string.Equals(_typed.Trim(), Confirmation, StringComparison.Ordinal); - - public ICommand EraseCommand { get; } - - public string EraseToolTip => Plan.IsEmpty ? Loc.L("Tooltips.Settings.Workspace.EmptyTrash.Disabled") : Loc.L("Tooltips.Settings.Workspace.TrashPlan.Action"); - - public string KeepToolTip => Loc.L("Tooltips.Settings.Workspace.TrashPlan.Keep"); - - private async Task EraseAsync() - { - if (!CanErase) return; - ClearError(); - IsBusy = true; - OnPropertyChanged(nameof(CanErase)); - try - { - var result = await _empty(Plan); - IsBusy = false; - Close(); - _emptied?.Invoke(result); - } - catch (Exception ex) when (ex is not OutOfMemoryException) - { - Log.Warning("workspace", "The workspace's trash was not emptied", ex); - ShowMessage(WorkspaceText.Failure(ex), ex.Message); - IsBusy = false; - OnPropertyChanged(nameof(CanErase)); - } - } -} diff --git a/src/Chronos.App/Workspace/WorkspaceTrashDialog.xaml b/src/Chronos.App/Workspace/WorkspaceTrashDialog.xaml deleted file mode 100644 index 081ba296..00000000 --- a/src/Chronos.App/Workspace/WorkspaceTrashDialog.xaml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -