Merge branch 'review2-p5a-fix2-desktop' into review2-p5a-int2
# Conflicts: # i18n/en/Editor.resx # i18n/en/Tooltips.resx # i18n/it/Tooltips.it.resx # src/Chronos.Data/Workspaces/WorkspaceSync.cs # tests/Chronos.Data.Tests/Workspaces/WorkspaceRecoveryTests.cs
This commit is contained in:
commit
47c660735f
30 files changed
+1021
-110
No files matched your search
+7
-1
@@ -191,12 +191,15 @@
|
||||
<data name="Editor.Motion.Smoothing" xml:space="preserve"><value>Path smoothing</value></data>
|
||||
<data name="Editor.Motion.Stabilize" xml:space="preserve"><value>Stabilise</value></data>
|
||||
<data name="Editor.OpenWorkspace.Existing" xml:space="preserve"><value>Existing</value></data>
|
||||
<data name="Editor.OpenWorkspace.Free" xml:space="preserve"><value>Free space</value></data>
|
||||
<data name="Editor.OpenWorkspace.Media" xml:space="preserve"><value>Media</value><comment>the photos the workspace copies: proxies or originals</comment></data>
|
||||
<data name="Editor.OpenWorkspace.New" xml:space="preserve"><value>New</value></data>
|
||||
<data name="Editor.OpenWorkspace.NoRoom" xml:space="preserve"><value>Not enough space</value></data>
|
||||
<data name="Editor.OpenWorkspace.Open" xml:space="preserve"><value>Open</value></data>
|
||||
<data name="Editor.OpenWorkspace.Originals" xml:space="preserve"><value>Originals</value></data>
|
||||
<data name="Editor.OpenWorkspace.Project" xml:space="preserve"><value>Project</value></data>
|
||||
<data name="Editor.OpenWorkspace.Proxies" xml:space="preserve"><value>Proxies</value></data>
|
||||
<data name="Editor.OpenWorkspace.Size" xml:space="preserve"><value>Copy size</value></data>
|
||||
<data name="Editor.OpenWorkspace.Title" xml:space="preserve"><value>Open in workspace</value></data>
|
||||
<data name="Editor.Optimise.Change" xml:space="preserve"><value>{0}: {1} → {2}</value><comment>invariant</comment></data>
|
||||
<data name="Editor.Optimise.ChangeRtl" xml:space="preserve"><value>{0}: {1} ← {2}</value><comment>invariant; right-to-left languages: the arrow points from the old value to the new one</comment></data>
|
||||
@@ -373,8 +376,11 @@
|
||||
<data name="Editor.Value.Pixels" xml:space="preserve"><value>{0} px</value><comment>invariant</comment></data>
|
||||
<data name="Editor.Value.Text" xml:space="preserve"><value>{0}</value><comment>invariant</comment></data>
|
||||
<data name="Editor.Value.Zoom" xml:space="preserve"><value>{0}×</value><comment>invariant</comment></data>
|
||||
<data name="Editor.Workspace.ChooseFolder" xml:space="preserve"><value>Choose folder</value></data>
|
||||
<data name="Editor.Workspace.Conflict.Later" xml:space="preserve"><value>Later</value></data>
|
||||
<data name="Editor.Workspace.Conflict.Message" xml:space="preserve"><value>{0} was changed in the library while you edited it here. These settings differ: keep yours, take the library's, or keep both as two projects.</value><comment>long; {0} project name</comment></data>
|
||||
<data name="Editor.Workspace.Conflict.NewerFormat" xml:space="preserve"><value>Saved by a newer Chronos</value><comment>long; the one line a conflict of format lists</comment></data>
|
||||
<data name="Editor.Workspace.Conflict.NewerMessage" xml:space="preserve"><value>{0} was saved in the library by a newer Chronos, whose settings this one does not merge with yours. Keep both as two projects, or update Chronos.</value><comment>long; {0} project name</comment></data>
|
||||
<data name="Editor.Workspace.Conflict.TakeHome" xml:space="preserve"><value>Take library's</value><comment>take the library's values where both sides changed a setting</comment></data>
|
||||
<data name="Editor.Workspace.Conflict.Title" xml:space="preserve"><value>Changed in the library too</value></data>
|
||||
<data name="Editor.Workspace.CopyFailed" xml:space="preserve"><value>Workspace copy failed</value></data>
|
||||
@@ -402,7 +408,7 @@
|
||||
<data name="Editor.Workspace.State.Ahead" xml:space="preserve"><value>Not sent</value><comment>versions saved here wait to be sent to the library</comment></data>
|
||||
<data name="Editor.Workspace.State.Behind" xml:space="preserve"><value>Library newer</value><comment>the library has versions the workspace has not taken</comment></data>
|
||||
<data name="Editor.Workspace.State.Conflict" xml:space="preserve"><value>Conflict</value></data>
|
||||
<data name="Editor.Workspace.State.Damaged" xml:space="preserve"><value>Damaged</value><comment>a version saved in the workspace cannot be read</comment></data>
|
||||
<data name="Editor.Workspace.State.Damaged" xml:space="preserve"><value>Damaged</value><comment>a version or the project file saved in the workspace cannot be read</comment></data>
|
||||
<data name="Editor.Workspace.State.Gone" xml:space="preserve"><value>Not in library</value></data>
|
||||
<data name="Editor.Workspace.State.InSync" xml:space="preserve"><value>In sync</value></data>
|
||||
<data name="Editor.Workspace.State.MediaRemoved" xml:space="preserve"><value>No media</value></data>
|
||||
|
||||
+5
-1
@@ -57,14 +57,17 @@
|
||||
<data name="Errors.Workspace.DeletedAtHome" xml:space="preserve"><value>This project was deleted in the library; nothing was removed. Discard changes removes its local copy.</value></data>
|
||||
<data name="Errors.Workspace.DiskFull" xml:space="preserve"><value>The workspace drive needs {0} GB more for this copy.</value><comment>{0} gigabytes missing</comment></data>
|
||||
<data name="Errors.Workspace.EditNotStored" xml:space="preserve"><value>The last edit could not be stored yet; it is tried again, try once more in a moment.</value></data>
|
||||
<data name="Errors.Workspace.FolderUnusable" xml:space="preserve"><value>{0} cannot be used as the workspace folder; the log says why.</value><comment>long; {0} folder</comment></data>
|
||||
<data name="Errors.Workspace.HomeCheck" xml:space="preserve"><value>The library's copy of this project does not match what was sent; nothing was removed.</value></data>
|
||||
<data name="Errors.Workspace.InsideLibrary" xml:space="preserve"><value>The workspace folder is inside a library; nothing is copied into it.</value></data>
|
||||
<data name="Errors.Workspace.InsideLibraryEdit" xml:space="preserve"><value>The workspace folder {0} is inside a library, where Edit copies nothing: keep Chronos's data folder outside your libraries.</value><comment>long</comment></data>
|
||||
<data name="Errors.Workspace.InsideLibraryEdit" xml:space="preserve"><value>The workspace folder {0} is inside a library, where Edit copies nothing: choose another workspace folder.</value><comment>long</comment></data>
|
||||
<data name="Errors.Workspace.InsideLibraryFolder" xml:space="preserve"><value>{0} is inside a library, where Edit copies nothing: choose a folder outside your libraries.</value><comment>long; {0} folder</comment></data>
|
||||
<data name="Errors.Workspace.InvalidName" xml:space="preserve"><value>A project name has 1 to 60 characters.</value></data>
|
||||
<data name="Errors.Workspace.MainKept" xml:space="preserve"><value>The Main project holds the sequence's own settings: it cannot be deleted.</value></data>
|
||||
<data name="Errors.Workspace.MediaChanged" xml:space="preserve"><value>The workspace's photos of this project changed; the editor reads them again.</value></data>
|
||||
<data name="Errors.Workspace.MediaMissing" xml:space="preserve"><value>The workspace holds no photos of this project; open it again to copy them.</value></data>
|
||||
<data name="Errors.Workspace.NameTaken" xml:space="preserve"><value>Another project of this sequence has that name.</value></data>
|
||||
<data name="Errors.Workspace.NoRoom" xml:space="preserve"><value>The drive of the workspace folder lacks room for this copy and the 0.5 GB the copy keeps free.</value></data>
|
||||
<data name="Errors.Workspace.NotCheckedOut" xml:space="preserve"><value>The project is no longer in the workspace.</value></data>
|
||||
<data name="Errors.Workspace.Offline" xml:space="preserve"><value>The library cannot be reached now; your work stays in the workspace and can be sent once it is back.</value></data>
|
||||
<data name="Errors.Workspace.OriginalsLater" xml:space="preserve"><value>The workspace copies proxies for now; copying the originals comes in a later version.</value></data>
|
||||
@@ -72,6 +75,7 @@
|
||||
<data name="Errors.Workspace.Parameters" xml:space="preserve"><value>The workspace copy job has no valid parameters.</value></data>
|
||||
<data name="Errors.Workspace.ProjectGone" xml:space="preserve"><value>This project is no longer in the library.</value></data>
|
||||
<data name="Errors.Workspace.ReadOnly" xml:space="preserve"><value>This project was saved by a newer Chronos: it opens read-only.</value></data>
|
||||
<data name="Errors.Workspace.ReadOnlyHome" xml:space="preserve"><value>The library is read-only now; your work stays in the workspace and can be sent once it is writable.</value></data>
|
||||
<data name="Errors.Workspace.Refused" xml:space="preserve"><value>The library refused a version of this project; the log says why.</value></data>
|
||||
<data name="Errors.Workspace.SequenceGone" xml:space="preserve"><value>This project's sequence is no longer in the library: only its local copy can be removed, from the picker's menu.</value><comment>long</comment></data>
|
||||
<data name="Errors.Workspace.Unsent" xml:space="preserve"><value>Some work is not in the library yet: send it first, or discard it.</value></data>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<data name="Server.Certificate.Trusted" xml:space="preserve"><value>TLS {0} trusted {1}</value></data>
|
||||
<data name="Server.Conflict.Cancel" xml:space="preserve"><value>Cancel</value></data>
|
||||
<data name="Server.Conflict.Changed" xml:space="preserve"><value>{0} differs</value><comment>{0} setting name</comment></data>
|
||||
<data name="Server.Conflict.Count" xml:space="preserve"><value>{0} ({1})</value><comment>invariant; {0} setting name, {1} number of photos it differs on</comment></data>
|
||||
<data name="Server.Conflict.Difference" xml:space="preserve"><value>{0} {1} here, {2} on the server</value><comment>long; {0} setting name, {1} value on this PC, {2} value on the server</comment></data>
|
||||
<data name="Server.Conflict.KeepMine.Message" xml:space="preserve"><value>The server copy of {0} will be replaced by this PC's settings.</value><comment>long; {0} sequence title</comment></data>
|
||||
<data name="Server.Conflict.KeepMine.Title" xml:space="preserve"><value>Keep this PC's settings?</value></data>
|
||||
|
||||
@@ -198,9 +198,18 @@
|
||||
<data name="Settings.Storage.Used" xml:space="preserve"><value>{0} used</value></data>
|
||||
<data name="Settings.Updates.Latest" xml:space="preserve"><value>Latest version</value></data>
|
||||
<data name="Settings.Workspace.AfterSave" xml:space="preserve"><value>After each version</value></data>
|
||||
<data name="Settings.Workspace.Change" xml:space="preserve"><value>Change…</value></data>
|
||||
<data name="Settings.Workspace.ChangeMessage" xml:space="preserve"><value>Edit lists the projects in {0} from now on. Those in {1} stay where they are, and come back if you choose that folder again.</value><comment>long; {0} the folder chosen, {1} the folder in use</comment></data>
|
||||
<data name="Settings.Workspace.ChangeTitle" xml:space="preserve"><value>Use another workspace folder?</value><comment>long; confirmation heading</comment></data>
|
||||
<data name="Settings.Workspace.Changed" xml:space="preserve"><value>Workspace folder changed</value></data>
|
||||
<data name="Settings.Workspace.ChooseTitle" xml:space="preserve"><value>Choose the workspace folder</value><comment>long; folder picker title</comment></data>
|
||||
<data name="Settings.Workspace.Folder" xml:space="preserve"><value>Folder</value></data>
|
||||
<data name="Settings.Workspace.Kept" xml:space="preserve"><value>Kept versions</value></data>
|
||||
<data name="Settings.Workspace.NotChanged" xml:space="preserve"><value>Folder not changed</value></data>
|
||||
<data name="Settings.Workspace.ProjectsFound" xml:space="preserve"><value>Projects found: {0}</value><comment>{0} count of the projects the folder chosen holds</comment></data>
|
||||
<data name="Settings.Workspace.ProjectsLeft" xml:space="preserve"><value>Projects left: {0}</value><comment>{0} count of the projects the folder in use keeps</comment></data>
|
||||
<data name="Settings.Workspace.Sync" xml:space="preserve"><value>Sync</value></data>
|
||||
<data name="Settings.Workspace.Use" xml:space="preserve"><value>Use folder</value></data>
|
||||
<data name="Settings.Workspace.Versions.one" xml:space="preserve"><value>{0} version</value></data>
|
||||
<data name="Settings.Workspace.Versions.other" xml:space="preserve"><value>{0} versions</value></data>
|
||||
</root>
|
||||
+10
-1
@@ -223,12 +223,14 @@
|
||||
<data name="Tooltips.Editor.NotApplicable.StabilizeOff" xml:space="preserve"><value>Not applicable: stabilisation is off</value></data>
|
||||
<data name="Tooltips.Editor.NotApplicable.StackOff" xml:space="preserve"><value>Not applicable: stacking is off</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Existing" xml:space="preserve"><value>Open a project the library has for this sequence; Main holds its settings as they are</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Free" xml:space="preserve"><value>Free space on the drive of the workspace folder; the copy keeps 0.5 GB free besides</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Name" xml:space="preserve"><value>The new project's name: 1 to 60 characters, each name once per sequence</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.New" xml:space="preserve"><value>A new project of this sequence, starting from Main</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Open" xml:space="preserve"><value>Copy the project's photos into the workspace, then open it there</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Originals" xml:space="preserve"><value>Copying the originals, to render on this PC, comes in a later update</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Projects" xml:space="preserve"><value>The sequence's projects in the library</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Proxies" xml:space="preserve"><value>Copy the proxies: light and fast to edit; renders use the library's originals</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Size" xml:space="preserve"><value>What the copy of the proxies writes into the workspace, as reckoned before it starts</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseAll" xml:space="preserve"><value>Let the advisor set every section from the analysis and list what changed</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseNone" xml:space="preserve"><value>The advisor never stacks on its own: a median erases moving stars</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseSection" xml:space="preserve"><value>Apply the advisor’s heavier choices for this section and list what changed · Ctrl+Z undoes</value></data>
|
||||
@@ -324,16 +326,20 @@
|
||||
<data name="Tooltips.Editor.Time.Rate" xml:space="preserve"><value>Photos shown per second of video; more plays the sequence faster</value></data>
|
||||
<data name="Tooltips.Editor.Unsaved.Discard" xml:space="preserve"><value>Close without the change; the stored settings stay as they were</value></data>
|
||||
<data name="Tooltips.Editor.Unsaved.Keep" xml:space="preserve"><value>Stay in the editor; saving is retried in the background</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.ChooseFolder" xml:space="preserve"><value>Choose a workspace folder outside your libraries; nothing is moved</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.Differences" xml:space="preserve"><value>The settings that differ: your value, then the library's</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.KeepMine" xml:space="preserve"><value>Keep your values of these settings; they are sent to the library</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.Later" xml:space="preserve"><value>Decide later and keep editing; Sync asks again</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.MediaChanged" xml:space="preserve"><value>The library added, removed, converted or verified photos of this sequence after the workspace copied it</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.NewerFormat" xml:space="preserve"><value>The library's project was saved by a newer Chronos: its settings are not merged with yours, so Keep mine and Take library's are not offered</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.OpenCopy" xml:space="preserve"><value>Open project {0}, which holds your versions</value><comment>long</comment></data>
|
||||
<data name="Tooltips.Editor.Workspace.SaveBoth" xml:space="preserve"><value>Keep the library's values in this project, and send yours to a new project “{0}”</value><comment>{0} the new project's name</comment></data>
|
||||
<data name="Tooltips.Editor.Workspace.SaveBothNewer" xml:space="preserve"><value>Send your versions to a new project “{0}”; this project takes the library's, read-only until Chronos is updated</value><comment>{0} the new project's name</comment></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Ahead" xml:space="preserve"><value>Versions saved here that wait to be sent to the library: {0}. Sync sends them</value><comment>{0} number of versions</comment></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Behind" xml:space="preserve"><value>Versions in the library this workspace has not taken yet: {0}. Sync takes them</value><comment>{0} number of versions</comment></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Conflict" xml:space="preserve"><value>You and the library changed the same settings: Sync to choose which to keep</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Damaged" xml:space="preserve"><value>A version saved here cannot be read (the log names its file): nothing is saved, sent or taken until it is repaired</value><comment>long</comment></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.DamagedCopy" xml:space="preserve"><value>This copy's project file cannot be read, so it cannot open; Remove local copy keeps its files in the workspace's trash</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Gone" xml:space="preserve"><value>The library no longer has this project or its sequence: nothing more can be sent; remove the local copy (its work is kept aside)</value><comment>long</comment></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.InSync" xml:space="preserve"><value>Every version of this project is in the library, and nothing changed since the last one</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.MediaRemoved" xml:space="preserve"><value>The workspace holds no photos of this project: opening it copies them again</value></data>
|
||||
@@ -709,6 +715,7 @@
|
||||
<data name="Tooltips.Settings.CacheFolder" xml:space="preserve"><value>Where frames spill and thumbnails are kept; a fast SSD helps · Enter applies, Esc reverts</value></data>
|
||||
<data name="Tooltips.Settings.CacheLimit" xml:space="preserve"><value>Largest size of the disk cache in GB · Enter applies, Esc reverts</value></data>
|
||||
<data name="Tooltips.Settings.CacheUsage" xml:space="preserve"><value>Space the cache uses and free space on its drive</value></data>
|
||||
<data name="Tooltips.Settings.ChangeWorkspace" xml:space="preserve"><value>Use another workspace folder, after a plan; nothing is moved: the projects of this one stay here</value></data>
|
||||
<data name="Tooltips.Settings.CheckForUpdates" xml:space="preserve"><value>Look for a new release when Chronos starts · no data is sent</value></data>
|
||||
<data name="Tooltips.Settings.ClearCache" xml:space="preserve"><value>Delete the cache contents now</value></data>
|
||||
<data name="Tooltips.Settings.ClearCacheAsk" xml:space="preserve"><value>Delete spilled frames and cached thumbnails; asks first</value></data>
|
||||
@@ -732,6 +739,7 @@
|
||||
<data name="Tooltips.Settings.KeepIndex" xml:space="preserve"><value>Keep the index as it is</value></data>
|
||||
<data name="Tooltips.Settings.KeepLogs" xml:space="preserve"><value>Log files last written longer ago are deleted</value></data>
|
||||
<data name="Tooltips.Settings.KeepSettings" xml:space="preserve"><value>Keep every setting as it is</value></data>
|
||||
<data name="Tooltips.Settings.KeepWorkspace" xml:space="preserve"><value>Keep the workspace folder in use</value></data>
|
||||
<data name="Tooltips.Settings.KeptVersions" xml:space="preserve"><value>How many of the library's versions each project keeps on this PC besides those not sent; older ones stay in the library</value></data>
|
||||
<data name="Tooltips.Settings.Language" xml:space="preserve"><value>Language of the interface · applies immediately</value></data>
|
||||
<data name="Tooltips.Settings.LogFileSize" xml:space="preserve"><value>A log file that reaches this size continues in a new numbered file</value></data>
|
||||
@@ -795,7 +803,8 @@
|
||||
<data name="Tooltips.Settings.Tier.Native" xml:space="preserve"><value>Every pixel is decoded</value></data>
|
||||
<data name="Tooltips.Settings.Tier.Unavailable" xml:space="preserve"><value>No decoder on this PC reads its pixels; such frames are left out of renders</value></data>
|
||||
<data name="Tooltips.Settings.UsageCounts" xml:space="preserve"><value>Send a daily anonymous count of versions and languages in use; nothing else, off by default</value></data>
|
||||
<data name="Tooltips.Settings.WorkspaceFolder" xml:space="preserve"><value>The workspace's folder (a fast disk is best); moving it comes in a later update</value></data>
|
||||
<data name="Tooltips.Settings.UseWorkspace" xml:space="preserve"><value>Edit uses this folder from now on; nothing is moved or deleted</value></data>
|
||||
<data name="Tooltips.Settings.WorkspaceFolder" xml:space="preserve"><value>The workspace's folder (a fast disk is best); Change uses another one, moving it comes in a later update</value></data>
|
||||
<data name="Tooltips.Settings.WorkspaceSync" xml:space="preserve"><value>Send each version you save to the library at once, and take the library's new versions</value></data>
|
||||
<data name="Tooltips.Setup.AllUsers" xml:space="preserve"><value>Install in Program Files for every account · asks for administrator approval</value></data>
|
||||
<data name="Tooltips.Setup.AllUsersOnly" xml:space="preserve"><value>{0} · it runs as a Windows service, so it installs for all users in Program Files</value></data>
|
||||
|
||||
@@ -183,12 +183,15 @@
|
||||
<data name="Editor.Motion.Smoothing" xml:space="preserve"><value>Smussatura percorso</value></data>
|
||||
<data name="Editor.Motion.Stabilize" xml:space="preserve"><value>Stabilizza</value></data>
|
||||
<data name="Editor.OpenWorkspace.Existing" xml:space="preserve"><value>Esistente</value></data>
|
||||
<data name="Editor.OpenWorkspace.Free" xml:space="preserve"><value>Spazio libero</value></data>
|
||||
<data name="Editor.OpenWorkspace.Media" xml:space="preserve"><value>Media</value></data>
|
||||
<data name="Editor.OpenWorkspace.New" xml:space="preserve"><value>Nuovo</value></data>
|
||||
<data name="Editor.OpenWorkspace.NoRoom" xml:space="preserve"><value>Spazio insufficiente</value></data>
|
||||
<data name="Editor.OpenWorkspace.Open" xml:space="preserve"><value>Apri</value></data>
|
||||
<data name="Editor.OpenWorkspace.Originals" xml:space="preserve"><value>Originali</value></data>
|
||||
<data name="Editor.OpenWorkspace.Project" xml:space="preserve"><value>Progetto</value></data>
|
||||
<data name="Editor.OpenWorkspace.Proxies" xml:space="preserve"><value>Proxy</value></data>
|
||||
<data name="Editor.OpenWorkspace.Size" xml:space="preserve"><value>Dimensione copia</value></data>
|
||||
<data name="Editor.OpenWorkspace.Title" xml:space="preserve"><value>Apri nello spazio di lavoro</value></data>
|
||||
<data name="Editor.Optimise.Done.one" xml:space="preserve"><value>{0} impostazione cambiata</value></data>
|
||||
<data name="Editor.Optimise.Done.other" xml:space="preserve"><value>{0} impostazioni cambiate</value></data>
|
||||
@@ -348,8 +351,11 @@
|
||||
<data name="Editor.Value.None" xml:space="preserve"><value>Nessuno</value></data>
|
||||
<data name="Editor.Value.Off" xml:space="preserve"><value>Disattivo</value></data>
|
||||
<data name="Editor.Value.On" xml:space="preserve"><value>Attivo</value></data>
|
||||
<data name="Editor.Workspace.ChooseFolder" xml:space="preserve"><value>Scegli cartella</value></data>
|
||||
<data name="Editor.Workspace.Conflict.Later" xml:space="preserve"><value>Più tardi</value></data>
|
||||
<data name="Editor.Workspace.Conflict.Message" xml:space="preserve"><value>{0} è stato modificato nella libreria mentre lo modificavi qui. Queste impostazioni sono diverse: tieni le tue, prendi quelle della libreria o tienile entrambe come due progetti.</value></data>
|
||||
<data name="Editor.Workspace.Conflict.NewerFormat" xml:space="preserve"><value>Salvato da un Chronos più recente</value></data>
|
||||
<data name="Editor.Workspace.Conflict.NewerMessage" xml:space="preserve"><value>{0} è stato salvato nella libreria da un Chronos più recente, le cui impostazioni questo non unisce alle tue. Tienile entrambe come due progetti, oppure aggiorna Chronos.</value></data>
|
||||
<data name="Editor.Workspace.Conflict.TakeHome" xml:space="preserve"><value>Prendi la libreria</value></data>
|
||||
<data name="Editor.Workspace.Conflict.Title" xml:space="preserve"><value>Modificato anche nella libreria</value></data>
|
||||
<data name="Editor.Workspace.CopyFailed" xml:space="preserve"><value>Copia di lavoro non riuscita</value></data>
|
||||
|
||||
@@ -57,14 +57,17 @@
|
||||
<data name="Errors.Workspace.DeletedAtHome" xml:space="preserve"><value>Questo progetto è stato eliminato nella libreria; non è stato rimosso nulla. Scarta modifiche rimuove la sua copia locale.</value></data>
|
||||
<data name="Errors.Workspace.DiskFull" xml:space="preserve"><value>Al disco dello spazio di lavoro servono altri {0} GB per questa copia.</value></data>
|
||||
<data name="Errors.Workspace.EditNotStored" xml:space="preserve"><value>L'ultima modifica non è ancora stata memorizzata; viene ritentata, riprova tra un momento.</value></data>
|
||||
<data name="Errors.Workspace.FolderUnusable" xml:space="preserve"><value>{0} non si può usare come cartella dello spazio di lavoro; il registro dice perché.</value></data>
|
||||
<data name="Errors.Workspace.HomeCheck" xml:space="preserve"><value>La copia di questo progetto nella libreria non corrisponde a quanto inviato; non è stato rimosso nulla.</value></data>
|
||||
<data name="Errors.Workspace.InsideLibrary" xml:space="preserve"><value>La cartella dello spazio di lavoro è dentro una libreria; non vi viene copiato nulla.</value></data>
|
||||
<data name="Errors.Workspace.InsideLibraryEdit" xml:space="preserve"><value>La cartella dello spazio di lavoro {0} è dentro una libreria, dove Modifica non copia nulla: tieni la cartella dei dati di Chronos fuori dalle tue librerie.</value></data>
|
||||
<data name="Errors.Workspace.InsideLibraryEdit" xml:space="preserve"><value>La cartella dello spazio di lavoro {0} è dentro una libreria, dove Modifica non copia nulla: scegli un'altra cartella dello spazio di lavoro.</value></data>
|
||||
<data name="Errors.Workspace.InsideLibraryFolder" xml:space="preserve"><value>{0} è dentro una libreria, dove Modifica non copia nulla: scegli una cartella fuori dalle tue librerie.</value></data>
|
||||
<data name="Errors.Workspace.InvalidName" xml:space="preserve"><value>Il nome di un progetto ha da 1 a 60 caratteri.</value></data>
|
||||
<data name="Errors.Workspace.MainKept" xml:space="preserve"><value>Il progetto Principale contiene le impostazioni della sequenza: non può essere eliminato.</value></data>
|
||||
<data name="Errors.Workspace.MediaChanged" xml:space="preserve"><value>Le foto di questo progetto nello spazio di lavoro sono cambiate; l'editor le rilegge.</value></data>
|
||||
<data name="Errors.Workspace.MediaMissing" xml:space="preserve"><value>Lo spazio di lavoro non ha foto di questo progetto; riaprilo per copiarle.</value></data>
|
||||
<data name="Errors.Workspace.NameTaken" xml:space="preserve"><value>Un altro progetto di questa sequenza ha già quel nome.</value></data>
|
||||
<data name="Errors.Workspace.NoRoom" xml:space="preserve"><value>All'unità della cartella dello spazio di lavoro manca lo spazio per questa copia e per gli 0,5 GB che la copia lascia liberi.</value></data>
|
||||
<data name="Errors.Workspace.NotCheckedOut" xml:space="preserve"><value>Il progetto non è più nello spazio di lavoro.</value></data>
|
||||
<data name="Errors.Workspace.Offline" xml:space="preserve"><value>La libreria ora non è raggiungibile; il tuo lavoro resta nello spazio di lavoro e potrà essere inviato quando torna.</value></data>
|
||||
<data name="Errors.Workspace.OriginalsLater" xml:space="preserve"><value>Per ora lo spazio di lavoro copia i proxy; la copia degli originali arriverà in una versione successiva.</value></data>
|
||||
@@ -72,6 +75,7 @@
|
||||
<data name="Errors.Workspace.Parameters" xml:space="preserve"><value>Il job di copia di lavoro non ha parametri validi.</value></data>
|
||||
<data name="Errors.Workspace.ProjectGone" xml:space="preserve"><value>Questo progetto non è più nella libreria.</value></data>
|
||||
<data name="Errors.Workspace.ReadOnly" xml:space="preserve"><value>Questo progetto è stato salvato da un Chronos più recente: si apre in sola lettura.</value></data>
|
||||
<data name="Errors.Workspace.ReadOnlyHome" xml:space="preserve"><value>La libreria ora è di sola lettura; il tuo lavoro resta nello spazio di lavoro e potrà essere inviato quando sarà scrivibile.</value></data>
|
||||
<data name="Errors.Workspace.Refused" xml:space="preserve"><value>La libreria ha rifiutato una versione di questo progetto; il log spiega il motivo.</value></data>
|
||||
<data name="Errors.Workspace.SequenceGone" xml:space="preserve"><value>La sequenza di questo progetto non è più nella libreria: si può solo rimuoverne la copia locale, dal menu del selettore.</value></data>
|
||||
<data name="Errors.Workspace.Unsent" xml:space="preserve"><value>Parte del lavoro non è ancora nella libreria: prima inviala oppure scartala.</value></data>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<data name="Server.Certificate.Trusted" xml:space="preserve"><value>TLS {0} attendibile dal {1}</value></data>
|
||||
<data name="Server.Conflict.Cancel" xml:space="preserve"><value>Annulla</value></data>
|
||||
<data name="Server.Conflict.Changed" xml:space="preserve"><value>{0}: valori diversi</value></data>
|
||||
<data name="Server.Conflict.Count" xml:space="preserve"><value>{0} ({1})</value></data>
|
||||
<data name="Server.Conflict.Difference" xml:space="preserve"><value>{0} {1} qui, {2} sul server</value></data>
|
||||
<data name="Server.Conflict.KeepMine.Message" xml:space="preserve"><value>La copia sul server di {0} sarà sostituita dalle impostazioni di questo PC.</value></data>
|
||||
<data name="Server.Conflict.KeepMine.Title" xml:space="preserve"><value>Tenere le impostazioni di questo PC?</value></data>
|
||||
|
||||
@@ -195,9 +195,18 @@
|
||||
<data name="Settings.Storage.Used" xml:space="preserve"><value>{0} usati</value></data>
|
||||
<data name="Settings.Updates.Latest" xml:space="preserve"><value>Ultima versione</value></data>
|
||||
<data name="Settings.Workspace.AfterSave" xml:space="preserve"><value>Dopo ogni versione</value></data>
|
||||
<data name="Settings.Workspace.Change" xml:space="preserve"><value>Cambia…</value></data>
|
||||
<data name="Settings.Workspace.ChangeMessage" xml:space="preserve"><value>Da ora Modifica elenca i progetti in {0}. Quelli in {1} restano dove sono e tornano se scegli di nuovo quella cartella.</value></data>
|
||||
<data name="Settings.Workspace.ChangeTitle" xml:space="preserve"><value>Usare un'altra cartella dello spazio di lavoro?</value></data>
|
||||
<data name="Settings.Workspace.Changed" xml:space="preserve"><value>Cartella cambiata</value></data>
|
||||
<data name="Settings.Workspace.ChooseTitle" xml:space="preserve"><value>Scegli la cartella dello spazio di lavoro</value></data>
|
||||
<data name="Settings.Workspace.Folder" xml:space="preserve"><value>Cartella</value></data>
|
||||
<data name="Settings.Workspace.Kept" xml:space="preserve"><value>Versioni tenute</value></data>
|
||||
<data name="Settings.Workspace.NotChanged" xml:space="preserve"><value>Cartella non cambiata</value></data>
|
||||
<data name="Settings.Workspace.ProjectsFound" xml:space="preserve"><value>Progetti trovati: {0}</value></data>
|
||||
<data name="Settings.Workspace.ProjectsLeft" xml:space="preserve"><value>Progetti lasciati: {0}</value></data>
|
||||
<data name="Settings.Workspace.Sync" xml:space="preserve"><value>Sincronizzazione</value></data>
|
||||
<data name="Settings.Workspace.Use" xml:space="preserve"><value>Usa cartella</value></data>
|
||||
<data name="Settings.Workspace.Versions.one" xml:space="preserve"><value>{0} versione</value></data>
|
||||
<data name="Settings.Workspace.Versions.other" xml:space="preserve"><value>{0} versioni</value></data>
|
||||
</root>
|
||||
@@ -223,12 +223,14 @@
|
||||
<data name="Tooltips.Editor.NotApplicable.StabilizeOff" xml:space="preserve"><value>Non applicabile: la stabilizzazione è spenta</value></data>
|
||||
<data name="Tooltips.Editor.NotApplicable.StackOff" xml:space="preserve"><value>Non applicabile: lo stacking è spento</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Existing" xml:space="preserve"><value>Apri un progetto che la libreria ha per questa sequenza; Principale ne contiene le impostazioni attuali</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Free" xml:space="preserve"><value>Spazio libero sull'unità della cartella dello spazio di lavoro; la copia lascia liberi anche 0,5 GB</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Name" xml:space="preserve"><value>Il nome del nuovo progetto: da 1 a 60 caratteri, ogni nome una sola volta per sequenza</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.New" xml:space="preserve"><value>Un nuovo progetto di questa sequenza, a partire da Principale</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Open" xml:space="preserve"><value>Copia le foto del progetto nello spazio di lavoro, poi aprilo lì</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Originals" xml:space="preserve"><value>La copia degli originali, per renderizzare su questo PC, arriverà in un aggiornamento successivo</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Projects" xml:space="preserve"><value>I progetti della sequenza nella libreria</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Proxies" xml:space="preserve"><value>Copia i proxy: leggeri e veloci da modificare; i render usano gli originali della libreria</value></data>
|
||||
<data name="Tooltips.Editor.OpenWorkspace.Size" xml:space="preserve"><value>Quanto scrive nello spazio di lavoro la copia dei proxy, come stimato prima che inizi</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseAll" xml:space="preserve"><value>Lascia che il consulente imposti ogni sezione dall’analisi ed elenchi cosa è cambiato</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseNone" xml:space="preserve"><value>Il consulente non fa mai stacking da solo: una mediana cancella le stelle in movimento</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseSection" xml:space="preserve"><value>Applica le scelte più incisive del consulente per questa sezione ed elenca cosa è cambiato · Ctrl+Z annulla</value></data>
|
||||
@@ -323,16 +325,20 @@
|
||||
<data name="Tooltips.Editor.Time.Rate" xml:space="preserve"><value>Foto mostrate per secondo di video; di più accelera la sequenza</value></data>
|
||||
<data name="Tooltips.Editor.Unsaved.Discard" xml:space="preserve"><value>Chiude senza la modifica; le impostazioni salvate restano com’erano</value></data>
|
||||
<data name="Tooltips.Editor.Unsaved.Keep" xml:space="preserve"><value>Resta nell’editor; il salvataggio viene ritentato in background</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.ChooseFolder" xml:space="preserve"><value>Scegli una cartella dello spazio di lavoro fuori dalle tue librerie; non viene spostato nulla</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.Differences" xml:space="preserve"><value>Le impostazioni diverse: il tuo valore, poi quello della libreria</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.KeepMine" xml:space="preserve"><value>Tieni i tuoi valori di queste impostazioni; vengono inviati alla libreria</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.Later" xml:space="preserve"><value>Decidi più tardi e continua a modificare; Sincronizza lo chiede di nuovo</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.MediaChanged" xml:space="preserve"><value>La libreria ha aggiunto, tolto, convertito o verificato foto di questa sequenza dopo che lo spazio di lavoro l'ha copiata</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.NewerFormat" xml:space="preserve"><value>Il progetto della libreria è stato salvato da un Chronos più recente: le sue impostazioni non si uniscono alle tue, quindi Tieni le mie e Prendi la libreria non sono proposti</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.OpenCopy" xml:space="preserve"><value>Apri il progetto {0}, che contiene le tue versioni</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.SaveBoth" xml:space="preserve"><value>Tieni i valori della libreria in questo progetto e invia i tuoi a un nuovo progetto «{0}»</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.SaveBothNewer" xml:space="preserve"><value>Invia le tue versioni a un nuovo progetto «{0}»; questo progetto prende quello della libreria, in sola lettura finché Chronos non viene aggiornato</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Ahead" xml:space="preserve"><value>Versioni salvate qui in attesa di essere inviate alla libreria: {0}. Sincronizza le invia</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Behind" xml:space="preserve"><value>Versioni nella libreria non ancora prese da questo spazio di lavoro: {0}. Sincronizza le prende</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Conflict" xml:space="preserve"><value>Tu e la libreria avete modificato le stesse impostazioni: sincronizza per scegliere quali tenere</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Damaged" xml:space="preserve"><value>Una versione salvata qui non è leggibile (il log indica il file): nulla viene salvato, inviato o ricevuto finché non è riparata</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.DamagedCopy" xml:space="preserve"><value>Il file di progetto di questa copia non si può leggere, quindi non si apre; Rimuovi copia locale ne tiene i file nel cestino dello spazio di lavoro</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.Gone" xml:space="preserve"><value>La libreria non ha più questo progetto o la sua sequenza: non si può più inviare nulla; rimuovi la copia locale (il suo lavoro resta da parte)</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.InSync" xml:space="preserve"><value>Ogni versione di questo progetto è nella libreria e nulla è cambiato dall'ultima</value></data>
|
||||
<data name="Tooltips.Editor.Workspace.State.MediaRemoved" xml:space="preserve"><value>Lo spazio di lavoro non ha foto di questo progetto: aprirlo le copia di nuovo</value></data>
|
||||
@@ -707,6 +713,7 @@
|
||||
<data name="Tooltips.Settings.CacheFolder" xml:space="preserve"><value>Dove vanno i fotogrammi temporanei e le miniature; un SSD veloce aiuta · Invio applica, Esc annulla</value></data>
|
||||
<data name="Tooltips.Settings.CacheLimit" xml:space="preserve"><value>Dimensione massima della cache su disco in GB · Invio applica, Esc annulla</value></data>
|
||||
<data name="Tooltips.Settings.CacheUsage" xml:space="preserve"><value>Spazio usato dalla cache e spazio libero sulla sua unità</value></data>
|
||||
<data name="Tooltips.Settings.ChangeWorkspace" xml:space="preserve"><value>Usa un'altra cartella dello spazio di lavoro, dopo un piano; non viene spostato nulla: i progetti di questa restano qui</value></data>
|
||||
<data name="Tooltips.Settings.CheckForUpdates" xml:space="preserve"><value>Cerca una nuova versione all'avvio di Chronos · nessun dato viene inviato</value></data>
|
||||
<data name="Tooltips.Settings.ClearCache" xml:space="preserve"><value>Elimina adesso il contenuto della cache</value></data>
|
||||
<data name="Tooltips.Settings.ClearCacheAsk" xml:space="preserve"><value>Elimina fotogrammi temporanei e miniature in cache; prima chiede conferma</value></data>
|
||||
@@ -730,6 +737,7 @@
|
||||
<data name="Tooltips.Settings.KeepIndex" xml:space="preserve"><value>Lascia l'indice com'è</value></data>
|
||||
<data name="Tooltips.Settings.KeepLogs" xml:space="preserve"><value>I file di log scritti l'ultima volta prima di questo periodo vengono eliminati</value></data>
|
||||
<data name="Tooltips.Settings.KeepSettings" xml:space="preserve"><value>Lascia ogni impostazione com'è</value></data>
|
||||
<data name="Tooltips.Settings.KeepWorkspace" xml:space="preserve"><value>Tieni la cartella dello spazio di lavoro in uso</value></data>
|
||||
<data name="Tooltips.Settings.KeptVersions" xml:space="preserve"><value>Quante versioni della libreria ogni progetto tiene su questo PC oltre a quelle non inviate; le più vecchie restano nella libreria</value></data>
|
||||
<data name="Tooltips.Settings.Language" xml:space="preserve"><value>Lingua dell'interfaccia · si applica subito</value></data>
|
||||
<data name="Tooltips.Settings.LogFileSize" xml:space="preserve"><value>Un file di log che raggiunge questa dimensione prosegue in un nuovo file numerato</value></data>
|
||||
@@ -793,7 +801,8 @@
|
||||
<data name="Tooltips.Settings.Tier.Native" xml:space="preserve"><value>Ogni pixel viene decodificato</value></data>
|
||||
<data name="Tooltips.Settings.Tier.Unavailable" xml:space="preserve"><value>Nessun decodificatore su questo PC ne legge i pixel; questi fotogrammi restano fuori dai rendering</value></data>
|
||||
<data name="Tooltips.Settings.UsageCounts" xml:space="preserve"><value>Invia ogni giorno un conteggio anonimo di versioni e lingue in uso; nient'altro, disattivato per impostazione predefinita</value></data>
|
||||
<data name="Tooltips.Settings.WorkspaceFolder" xml:space="preserve"><value>La cartella dello spazio di lavoro (meglio un disco veloce); spostarla arriverà in un aggiornamento successivo</value></data>
|
||||
<data name="Tooltips.Settings.UseWorkspace" xml:space="preserve"><value>Modifica usa questa cartella da ora; nulla viene spostato o eliminato</value></data>
|
||||
<data name="Tooltips.Settings.WorkspaceFolder" xml:space="preserve"><value>La cartella dello spazio di lavoro (meglio un disco veloce); Cambia ne usa un'altra, spostarla arriverà in un aggiornamento successivo</value></data>
|
||||
<data name="Tooltips.Settings.WorkspaceSync" xml:space="preserve"><value>Invia subito alla libreria ogni versione che salvi e prendi le nuove versioni della libreria</value></data>
|
||||
<data name="Tooltips.Setup.AllUsers" xml:space="preserve"><value>Installa in Programmi per tutti gli account · chiede l'autorizzazione di amministratore</value></data>
|
||||
<data name="Tooltips.Setup.AllUsersOnly" xml:space="preserve"><value>{0} · è un servizio di Windows, quindi si installa per tutti gli utenti in Programmi</value></data>
|
||||
|
||||
@@ -285,6 +285,8 @@ public sealed class SequencePickerViewModel : LocalizedViewModel
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (generation != _generation) return;
|
||||
// Its working state cannot be read: there is no state to ask for.
|
||||
if (item.IsDamaged) continue;
|
||||
try
|
||||
{
|
||||
item.Status = await Shell.Services.Workspace.StatusAsync(item.ProjectId);
|
||||
|
||||
@@ -232,6 +232,12 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
KeepOpenSequence();
|
||||
return;
|
||||
}
|
||||
// A copy whose working state cannot be read cannot open: its removal plan is what it offers.
|
||||
if (item.IsDamaged)
|
||||
{
|
||||
await RemoveProjectCopyAsync(item);
|
||||
return;
|
||||
}
|
||||
await OpenProjectAsync(item.SequenceId, item.ProjectId);
|
||||
}
|
||||
|
||||
@@ -589,6 +595,8 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
{ Main: true } => (await workspace.ProjectsOfAsync(row.Id)).FirstOrDefault(p => p.IsMain),
|
||||
_ => await workspace.LastUsedAsync(row.Id),
|
||||
};
|
||||
// Its working state cannot be read: nothing is checked out over it (the picker offers Remove local copy).
|
||||
if (entry is { Damaged: true }) throw new WorkspaceException(Loc.L("Errors.Workspace.Damaged"));
|
||||
if (entry is { HasMedia: true })
|
||||
{
|
||||
workspace.Remember(row.Id, entry.ProjectId);
|
||||
@@ -613,16 +621,43 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
}
|
||||
(projectId, newName) = (choice.ProjectId, choice.NewName);
|
||||
}
|
||||
var checkout = await workspace.CheckoutAsync(row.Id, projectId, newName);
|
||||
WorkspaceCheckout checkout;
|
||||
try
|
||||
{
|
||||
checkout = await workspace.CheckoutAsync(row.Id, projectId, newName);
|
||||
}
|
||||
catch (WorkspaceException ex) when (ex.FolderRefused)
|
||||
{
|
||||
// Nothing was written: the way on is another workspace folder, offered from the refusal.
|
||||
Log.Info("workspace", $"Sequence {row.Id} not checked out: {ex.Message}");
|
||||
Shell.Notify(Loc.L("Editor.Workspace.OpenFailed"), ex.Message, Loc.L("Editor.Workspace.ChooseFolder"), Loc.L("Tooltips.Editor.Workspace.ChooseFolder"),
|
||||
() => _ = WorkspaceFolderChange.ChooseAsync(Shell), isError: true);
|
||||
_afterOpen = null;
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return null;
|
||||
}
|
||||
await FollowCopyAsync(row.Id, row.DisplayTitle, checkout.Project.Id, checkout.Copy);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>"Open in workspace": the projects of the sequence's home and the media; null when closed without a choice.</summary>
|
||||
/// <summary>
|
||||
/// "Open in workspace": the projects of the sequence's home, the media, what their copy writes and the room the
|
||||
/// workspace's drive has; null when closed without a choice.
|
||||
/// </summary>
|
||||
private async Task<OpenChoice?> AskProjectAsync(WorkspaceHost workspace, Sequence row)
|
||||
{
|
||||
var projects = await workspace.HomeProjectsAsync(row.Id);
|
||||
var dialog = new OpenInWorkspaceDialogViewModel(row.DisplayTitle, projects, d => CloseDialog(d));
|
||||
WorkspaceCopyFacts? copy = null;
|
||||
try
|
||||
{
|
||||
copy = await workspace.CopyFactsAsync(row.Id);
|
||||
}
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or DatabaseException or UnauthorizedAccessException)
|
||||
{
|
||||
// Only shown: the copy measures again before it writes.
|
||||
Log.Info("workspace", $"The copy of sequence {row.Id} could not be measured: {ex.Message}");
|
||||
}
|
||||
var dialog = new OpenInWorkspaceDialogViewModel(row.DisplayTitle, projects, d => CloseDialog(d), copy: copy);
|
||||
// The picker or the open sequence shows behind the dialog meanwhile, not the progress bar.
|
||||
IsLoading = false;
|
||||
OpenDialog(dialog);
|
||||
@@ -679,6 +714,23 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
Shell.Notify(Loc.L(fetch.ProjectId is null ? "Editor.Proxies.Failed" : "Editor.Workspace.CopyFailed"), job.Error ?? fetch.Title, Loc.L("Shell.Nav.Jobs"),
|
||||
Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs), isError: true);
|
||||
break;
|
||||
// The user cancelled the first copy of a project's media: the photos it wrote go (a failed one keeps them for its retry).
|
||||
case JobState.Cancelled when fetch.ProjectId is { } cancelled:
|
||||
_ = RemovePartialMediaAsync(cancelled);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RemovePartialMediaAsync(Guid projectId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Shell.Services.Workspace.RemovePartialMediaAsync(projectId);
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
// Copies the library can make again: they wait for the next copy, which checks each.
|
||||
Log.Warning("workspace", $"The media of a cancelled copy of project {projectId} could not be removed", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -522,17 +522,21 @@
|
||||
|
||||
<!-- ================= Workspace (owner review 2, R8) ================= -->
|
||||
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Workspace}">
|
||||
<!-- The folder is shown and opened here; moving it (a plan and a confirmation) comes with phase 5c. -->
|
||||
<!-- The folder is shown, opened and changed here (another folder after its plan; nothing is moved: moving it with its projects comes with phase 5c). -->
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Workspace.Folder}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Style="{StaticResource TextBox.Path}" IsReadOnly="True" Text="{Binding WorkspaceRows.Folder, Mode=OneWay}" ToolTip="{l:Loc Tooltips.Settings.WorkspaceFolder}"
|
||||
AutomationProperties.Name="{l:Loc Settings.Workspace.Folder}" />
|
||||
<Button Grid.Column="1" Content="{l:Loc Common.Open}" Command="{Binding WorkspaceRows.OpenCommand}" ToolTip="{l:Loc Tooltips.Settings.OpenWorkspace}"
|
||||
Margin="10,0,0,0" />
|
||||
<Button Grid.Column="2" Content="{l:Loc Settings.Workspace.Change}" Command="{Binding WorkspaceRows.ChangeCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Settings.ChangeWorkspace}" Margin="8,0,0,0"
|
||||
Visibility="{Binding WorkspaceRows.CanChange, Converter={StaticResource BoolToVisibility}}" />
|
||||
</Grid>
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Workspace.Sync}">
|
||||
|
||||
@@ -8,6 +8,7 @@ using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Server;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.App.Workspace;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Import;
|
||||
@@ -168,7 +169,7 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
Logs = new LogSettingsRows(_s, Save);
|
||||
|
||||
// ---- Workspace ----
|
||||
WorkspaceRows = new WorkspaceSettingsRows(_s, Save, () => Shell.Services.Workspace.Root, OpenWorkspaceFolder);
|
||||
WorkspaceRows = new WorkspaceSettingsRows(_s, Save, () => Shell.Services.Workspace.Root, OpenWorkspaceFolder, ChangeWorkspaceFolderAsync);
|
||||
|
||||
// ---- Storage ----
|
||||
CacheFolder = new EditableField(CacheStore.Folder(shell.Services.Environment, _s), v => ArchiveLocations.Validate(v), v =>
|
||||
@@ -740,6 +741,13 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Another workspace folder, after its plan (nothing is moved): Edit lists its projects from then on.</summary>
|
||||
private async Task ChangeWorkspaceFolderAsync()
|
||||
{
|
||||
await WorkspaceFolderChange.ChooseAsync(Shell);
|
||||
WorkspaceRows.Refresh();
|
||||
}
|
||||
|
||||
// ---------------- Server ----------------
|
||||
|
||||
public EditableField DefaultServer { get; }
|
||||
|
||||
@@ -174,29 +174,49 @@ public static class SyncText
|
||||
/// <summary>
|
||||
/// As <see cref="Differences(IEnumerable{SettingsDifference}, int)"/>, each line with both values worded by
|
||||
/// <paramref name="worded"/> (setting, this side's value, the other side's) instead of "here, on the server": a
|
||||
/// workspace project against its library, a version against now.
|
||||
/// workspace project against its library, a version against now. One setting differing on several photos (positions
|
||||
/// parked by photo) is one line with their count: "Excluded frames (3)".
|
||||
/// </summary>
|
||||
public static IReadOnlyList<string> Differences(IEnumerable<SettingsDifference> differences, int max, Func<string, string, string, string>? worded)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(differences);
|
||||
worded ??= (label, mine, server) => Loc.L("Server.Conflict.Difference", label, mine, server);
|
||||
var lines = new List<string>();
|
||||
var shown = new HashSet<string>(StringComparer.Ordinal);
|
||||
// One line per setting, in the order met; the photos each differs on counted.
|
||||
var settings = new List<(string Key, string? Field, SettingsDifference First, HashSet<string> Photos)>();
|
||||
var index = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
foreach (var difference in differences)
|
||||
{
|
||||
var (key, field) = Setting(difference.Path);
|
||||
if (!shown.Add(key)) continue;
|
||||
if (!index.TryGetValue(key, out var at))
|
||||
{
|
||||
index[key] = at = settings.Count;
|
||||
settings.Add((key, field, difference, new HashSet<string>(StringComparer.Ordinal)));
|
||||
}
|
||||
if (PhotoOf(difference.Path) is { } photo) settings[at].Photos.Add(photo);
|
||||
}
|
||||
var lines = new List<string>();
|
||||
foreach (var (key, field, difference, photos) in settings)
|
||||
{
|
||||
var label = Loc.L(key);
|
||||
var metadata = difference.Path.StartsWith(SyncRules.MetadataPath, StringComparison.Ordinal);
|
||||
lines.Add((metadata ? Text(difference.Mine) : Value(difference.Mine, field)) is { } mine
|
||||
&& (metadata ? Text(difference.Theirs) : Value(difference.Theirs, field)) is { } server
|
||||
? worded(label, mine, server)
|
||||
: Loc.L("Server.Conflict.Changed", label));
|
||||
lines.Add(photos.Count > 1 ? Loc.L("Server.Conflict.Count", label, Formatting.Count(photos.Count))
|
||||
: (metadata ? Text(difference.Mine) : Value(difference.Mine, field)) is { } mine
|
||||
&& (metadata ? Text(difference.Theirs) : Value(difference.Theirs, field)) is { } server
|
||||
? worded(label, mine, server)
|
||||
: Loc.L("Server.Conflict.Changed", label));
|
||||
if (lines.Count == max) break;
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
/// <summary>The photo a path of positions parked by photo names ("pendingFrames.<photo>.excluded"); null for any other path.</summary>
|
||||
private static string? PhotoOf(string path)
|
||||
{
|
||||
if (!path.StartsWith(PendingPrefix, StringComparison.Ordinal)) return null;
|
||||
var flag = path.LastIndexOf('.');
|
||||
return flag > PendingPrefix.Length ? path[PendingPrefix.Length..flag] : null;
|
||||
}
|
||||
|
||||
/// <summary>The row's buttons, in the order the mockup shows them.</summary>
|
||||
public static IReadOnlyList<SyncAction> Actions(SyncEntry entry, SyncRights rights)
|
||||
{
|
||||
|
||||
@@ -5,14 +5,14 @@ using Chronos.Ui.Mvvm;
|
||||
namespace Chronos.App.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Workspace (owner review 2, R8): the workspace folder (shown with Open; moving it, with its plan and
|
||||
/// confirmation, comes with phase 5c), Sync automatically (a version saved is sent to its home at once, and the home's
|
||||
/// Settings › Workspace (owner review 2, R8): the workspace folder (shown with Open, and Change, which uses another
|
||||
/// folder after a plan without moving anything; moving it with its projects comes with phase 5c), Sync automatically (a version saved is sent to its home at once, and the home's
|
||||
/// new versions taken; on by default) and Kept versions (the versions taken from the home a project keeps in the
|
||||
/// workspace besides its base and those not sent; 20 by default). Each choice is stored and saved at once. A value set
|
||||
/// elsewhere (an imported or hand-edited settings file) is listed with the presets; one below 1 is shown as 1, as the
|
||||
/// workspace applies it.
|
||||
/// </summary>
|
||||
public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Func<string> folder, Action open) : ObservableObject
|
||||
public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Func<string> folder, Action open, Func<Task>? change = null) : ObservableObject
|
||||
{
|
||||
public static readonly int[] KeptPresets = [5, 10, 20, 50, 100, 200];
|
||||
|
||||
@@ -22,6 +22,11 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun
|
||||
/// <summary>Shows the folder in Explorer.</summary>
|
||||
public RelayCommand OpenCommand { get; } = new(open);
|
||||
|
||||
/// <summary>Uses another folder, after its plan (WorkspaceFolderChange); none where the folder cannot change.</summary>
|
||||
public AsyncRelayCommand ChangeCommand { get; } = new(change ?? (() => Task.CompletedTask), () => change is not null);
|
||||
|
||||
public bool CanChange => change is not null;
|
||||
|
||||
public bool AutoSync
|
||||
{
|
||||
get => settings.WorkspaceAutoSync;
|
||||
@@ -50,7 +55,7 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The defaults of every row (Reset section); the caller saves. The folder stays (moving it is phase 5c).</summary>
|
||||
/// <summary>The defaults of every row (Reset section); the caller saves. The folder stays (Change chooses it, after its plan).</summary>
|
||||
public void Reset()
|
||||
{
|
||||
var defaults = new AppSettings();
|
||||
|
||||
@@ -559,7 +559,7 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
if (background && _asking is { IsClosed: false }) return;
|
||||
var lines = WorkspaceText.ConflictLines(conflict.Differences, 10);
|
||||
var dialog = new ConflictDialogViewModel(Name, WorkspaceHost.SiblingName(_source.Workspace?.Name ?? Name), lines, choice => ResolveAsync(choice, conflict),
|
||||
_ui.CloseDialog);
|
||||
_ui.CloseDialog, conflict.NewerFormat);
|
||||
if (!background)
|
||||
{
|
||||
// Asked now: one still waiting from the background (or showing, which this one replaces) would only repeat an older list.
|
||||
|
||||
@@ -49,11 +49,20 @@ public sealed class OpenInWorkspaceDialogViewModel : ArchiveDialogViewModel
|
||||
private bool _isNew;
|
||||
|
||||
/// <param name="taken">The names a new project cannot take (default: those of <paramref name="projects"/>).</param>
|
||||
/// <param name="copy">What the copy of the media writes and the free space of the workspace's drive; null when not measured (shown as nothing).</param>
|
||||
public OpenInWorkspaceDialogViewModel(string sequenceTitle, IReadOnlyList<SequenceProject> projects, Action<ArchiveDialogViewModel> close,
|
||||
IReadOnlyList<string>? taken = null)
|
||||
IReadOnlyList<string>? taken = null, WorkspaceCopyFacts? copy = null)
|
||||
: base(close)
|
||||
{
|
||||
SequenceTitle = sequenceTitle;
|
||||
Copy = copy;
|
||||
CopyFacts = copy is null ? []
|
||||
:
|
||||
[
|
||||
new DialogFact(Loc.L("Editor.OpenWorkspace.Size"), Formatting.Bytes(copy.Bytes), Reason: Loc.L("Tooltips.Editor.OpenWorkspace.Size")),
|
||||
new DialogFact(Loc.L("Editor.OpenWorkspace.Free"), copy.Free is { } free ? Formatting.Bytes(free) : Loc.L("Server.Sync.None"),
|
||||
Reason: Loc.L(copy.TooLittleSpace ? "Errors.Workspace.NoRoom" : "Tooltips.Editor.OpenWorkspace.Free")),
|
||||
];
|
||||
Projects = [.. projects.OrderByDescending(p => p.IsMain).Select(p => new ProjectOption(p))];
|
||||
_selected = Projects.FirstOrDefault();
|
||||
_isNew = Projects.Count == 0;
|
||||
@@ -68,6 +77,15 @@ public sealed class OpenInWorkspaceDialogViewModel : ArchiveDialogViewModel
|
||||
|
||||
public string SequenceTitle { get; }
|
||||
|
||||
/// <summary>The copy's bytes and the drive's free space, when measured.</summary>
|
||||
public WorkspaceCopyFacts? Copy { get; }
|
||||
|
||||
/// <summary>"Copy size" and "Free space", under the media.</summary>
|
||||
public IReadOnlyList<DialogFact> CopyFacts { get; }
|
||||
|
||||
/// <summary>The drive lacks room for the copy: the free space says so (the copy would stop saying how much is missing).</summary>
|
||||
public bool IsShortOfSpace => Copy?.TooLittleSpace == true;
|
||||
|
||||
public string Heading => Loc.L("Editor.OpenWorkspace.Title");
|
||||
|
||||
public IReadOnlyList<ProjectOption> Projects { get; }
|
||||
@@ -381,25 +399,35 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
|
||||
/// <summary>
|
||||
/// A sync that met settings both sides changed (owner review 2, R8: asked only on real conflicts): what differs, then
|
||||
/// Keep mine, Take the library's, or Save both (this workspace's versions go to a sibling project). Later leaves the
|
||||
/// conflict for the next Sync; editing goes on meanwhile.
|
||||
/// conflict for the next Sync; editing goes on meanwhile. A conflict of format (the library's project saved by a newer
|
||||
/// Chronos, <see cref="WorkspaceConflict.NewerFormat"/>) cannot be merged either way: only Save both and Later are offered.
|
||||
/// </summary>
|
||||
public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly Func<ConflictChoice, Task> _resolve;
|
||||
|
||||
/// <param name="newerFormat">The library holds a newer Chronos's settings: nothing is merged, Save both is the only choice.</param>
|
||||
public ConflictDialogViewModel(string projectName, string siblingName, IReadOnlyList<string> differences, Func<ConflictChoice, Task> resolve,
|
||||
Action<ArchiveDialogViewModel> close)
|
||||
Action<ArchiveDialogViewModel> close, bool newerFormat = false)
|
||||
: base(close)
|
||||
{
|
||||
ProjectName = projectName;
|
||||
SiblingName = siblingName;
|
||||
Differences = differences;
|
||||
IsNewerFormat = newerFormat;
|
||||
// The format's number says nothing to the user: the line names the cause.
|
||||
Differences = newerFormat ? [Loc.L("Editor.Workspace.Conflict.NewerFormat")] : differences;
|
||||
_resolve = resolve;
|
||||
KeepMineCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.KeepMine), () => !IsBusy);
|
||||
TakeHomeCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.TakeServer), () => !IsBusy);
|
||||
KeepMineCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.KeepMine), () => !IsBusy && CanMerge);
|
||||
TakeHomeCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.TakeServer), () => !IsBusy && CanMerge);
|
||||
SaveBothCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.SaveBoth), () => !IsBusy);
|
||||
}
|
||||
|
||||
/// <summary>The library's project was saved by a newer Chronos.</summary>
|
||||
public bool IsNewerFormat { get; }
|
||||
|
||||
/// <summary>Keep mine and Take the library's are offered (not for a conflict of format, which neither can settle).</summary>
|
||||
public bool CanMerge => !IsNewerFormat;
|
||||
|
||||
public string ProjectName { get; }
|
||||
|
||||
/// <summary>The project Save both makes for this workspace's versions.</summary>
|
||||
@@ -407,17 +435,19 @@ public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
|
||||
|
||||
public string Heading => Loc.L("Editor.Workspace.Conflict.Title");
|
||||
|
||||
public string Message => Loc.L("Editor.Workspace.Conflict.Message", ProjectName);
|
||||
public string Message => Loc.L(IsNewerFormat ? "Editor.Workspace.Conflict.NewerMessage" : "Editor.Workspace.Conflict.Message", ProjectName);
|
||||
|
||||
public IReadOnlyList<string> Differences { get; }
|
||||
|
||||
public string DifferencesToolTip => Loc.L(IsNewerFormat ? "Tooltips.Editor.Workspace.NewerFormat" : "Tooltips.Editor.Workspace.Differences");
|
||||
|
||||
public ICommand KeepMineCommand { get; }
|
||||
|
||||
public ICommand TakeHomeCommand { get; }
|
||||
|
||||
public ICommand SaveBothCommand { get; }
|
||||
|
||||
public string SaveBothToolTip => Loc.L("Tooltips.Editor.Workspace.SaveBoth", SiblingName);
|
||||
public string SaveBothToolTip => Loc.L(IsNewerFormat ? "Tooltips.Editor.Workspace.SaveBothNewer" : "Tooltips.Editor.Workspace.SaveBoth", SiblingName);
|
||||
|
||||
private async Task ResolveAsync(ConflictChoice choice)
|
||||
{
|
||||
@@ -442,7 +472,8 @@ public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
|
||||
/// "Remove local copy": the plan (files and size of the copy; versions not sent and changes not saved), then Remove
|
||||
/// (only when everything is at the library), Send first (sends, then removes), or Discard changes (removes once the
|
||||
/// user typed the project's name; the unsent work is kept aside in the workspace's trash). A project the library no
|
||||
/// longer has (<see cref="WorkspaceRemovalPlan.Gone"/>) can only be discarded that way.
|
||||
/// longer has (<see cref="WorkspaceRemovalPlan.Gone"/>), or a copy whose working state cannot be read
|
||||
/// (<see cref="WorkspaceRemovalPlan.Damaged"/>), can only be discarded that way.
|
||||
/// </summary>
|
||||
public sealed class RemoveCopyDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
@@ -466,7 +497,7 @@ public sealed class RemoveCopyDialogViewModel : ArchiveDialogViewModel
|
||||
new DialogFact(Loc.L("Editor.RemoveCopy.Changed"), Loc.L(plan.Modified ? "Editor.RemoveCopy.Yes" : "Editor.RemoveCopy.No")),
|
||||
];
|
||||
RemoveCommand = new AsyncRelayCommand(() => RunAsync(() => _remove(false)), () => !IsBusy && plan.IsSafe && !plan.Offline && !plan.Gone);
|
||||
SendFirstCommand = new AsyncRelayCommand(() => RunAsync(_sendFirst), () => !IsBusy && !plan.IsSafe && !plan.Conflict && !plan.Offline && !plan.Gone);
|
||||
SendFirstCommand = new AsyncRelayCommand(() => RunAsync(_sendFirst), () => !IsBusy && !plan.IsSafe && !plan.Conflict && !plan.Offline && !plan.Gone && !plan.Damaged);
|
||||
DiscardCommand = new AsyncRelayCommand(DiscardAsync, () => !IsBusy && HasUnsent);
|
||||
}
|
||||
|
||||
@@ -485,12 +516,14 @@ public sealed class RemoveCopyDialogViewModel : ArchiveDialogViewModel
|
||||
|
||||
public ICommand DiscardCommand { get; }
|
||||
|
||||
public string RemoveToolTip => Plan.Gone ? Loc.L("Errors.Workspace.ProjectGone")
|
||||
public string RemoveToolTip => Plan.Damaged ? Loc.L("Errors.Workspace.Damaged")
|
||||
: Plan.Gone ? Loc.L("Errors.Workspace.ProjectGone")
|
||||
: !Plan.IsSafe ? Loc.L("Errors.Workspace.Unsent")
|
||||
: Plan.Offline ? Loc.L("Errors.Workspace.Offline")
|
||||
: Loc.L("Tooltips.Editor.RemoveCopy.Remove");
|
||||
|
||||
public string SendFirstToolTip => Plan.Gone ? Loc.L("Errors.Workspace.ProjectGone")
|
||||
public string SendFirstToolTip => Plan.Damaged ? Loc.L("Errors.Workspace.Damaged")
|
||||
: Plan.Gone ? Loc.L("Errors.Workspace.ProjectGone")
|
||||
: Plan.Conflict ? Loc.L("Errors.Workspace.Conflict")
|
||||
: Plan.Offline ? Loc.L("Errors.Workspace.Offline")
|
||||
: Loc.L("Tooltips.Editor.RemoveCopy.SendFirst");
|
||||
|
||||
@@ -51,6 +51,23 @@
|
||||
ToolTip="{l:Loc Tooltips.Editor.OpenWorkspace.Originals}" ToolTipService.ShowOnDisabled="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<!-- What the copy writes and the room the workspace's drive has for it. -->
|
||||
<ItemsControl ItemsSource="{Binding CopyFacts}" Focusable="False" Margin="0,14,0,0" Grid.IsSharedSizeScope="True">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type ar:DialogFact}">
|
||||
<Grid Margin="0,0,0,6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="116" SharedSizeGroup="CopyFactLabel" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.DialogLabel}" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Value}" TextTrimming="CharacterEllipsis" ToolTip="{Binding ToolTip}" Typography.NumeralAlignment="Tabular" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<ui:StatusGlyph Kind="Warning" Text="{l:Loc Editor.OpenWorkspace.NoRoom}" ToolTip="{l:Loc Errors.Workspace.NoRoom}" FontSize="12" HorizontalAlignment="Left"
|
||||
Margin="116,2,0,0" Visibility="{Binding IsShortOfSpace, Converter={StaticResource BoolToVisibility}}" />
|
||||
<DockPanel Margin="0,20,0,0">
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Editor.OpenWorkspace.Open}" Command="{Binding OpenCommand}"
|
||||
ToolTip="{Binding OpenToolTip}" ToolTipService.ShowOnDisabled="True" IsDefault="True" MinWidth="96" Margin="8,0,0,0" />
|
||||
@@ -188,13 +205,13 @@
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- A sync that met settings both sides changed: what differs, then Keep mine, Take the library's, Save both, or Later. -->
|
||||
<!-- A sync that met settings both sides changed: what differs, then Keep mine, Take the library's, Save both, or Later (only Save both and Later for a newer Chronos's project). -->
|
||||
<DataTemplate DataType="{x:Type ws:ConflictDialogViewModel}">
|
||||
<Border Style="{StaticResource Border.Dialog}" Width="560">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" TextWrapping="Wrap" TextTrimming="None" />
|
||||
<TextBlock Text="{Binding Message}" Margin="0,8,0,0" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" LineHeight="18" />
|
||||
<Border Style="{StaticResource Border.Card}" Margin="0,14,0,0" Padding="12,10" ToolTip="{l:Loc Tooltips.Editor.Workspace.Differences}">
|
||||
<Border Style="{StaticResource Border.Card}" Margin="0,14,0,0" Padding="12,10" ToolTip="{Binding DifferencesToolTip}">
|
||||
<ItemsControl ItemsSource="{Binding Differences}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
@@ -206,11 +223,17 @@
|
||||
<WrapPanel HorizontalAlignment="Right" Margin="0,20,0,0">
|
||||
<Button Content="{l:Loc Editor.Workspace.Conflict.Later}" Command="{Binding CloseCommand}" ToolTip="{l:Loc Tooltips.Editor.Workspace.Later}" IsCancel="True"
|
||||
MinWidth="96" Margin="0,0,8,8" />
|
||||
<Button Content="{l:Loc Server.Sync.Action.SaveBoth}" Command="{Binding SaveBothCommand}" ToolTip="{Binding SaveBothToolTip}" MinWidth="96" Margin="0,0,8,8" />
|
||||
<Button Content="{l:Loc Server.Sync.Action.SaveBoth}" Command="{Binding SaveBothCommand}" ToolTip="{Binding SaveBothToolTip}" MinWidth="96" Margin="0,0,8,8"
|
||||
Visibility="{Binding CanMerge, Converter={StaticResource BoolToVisibility}}" />
|
||||
<Button Content="{l:Loc Editor.Workspace.Conflict.TakeHome}" Command="{Binding TakeHomeCommand}" ToolTip="{l:Loc Tooltips.Editor.Workspace.TakeHome}"
|
||||
MinWidth="96" Margin="0,0,8,8" />
|
||||
MinWidth="96" Margin="0,0,8,8" Visibility="{Binding CanMerge, Converter={StaticResource BoolToVisibility}}" />
|
||||
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Server.Sync.Action.KeepMine}" Command="{Binding KeepMineCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Workspace.KeepMine}" IsDefault="True" MinWidth="96" Margin="0,0,0,8" />
|
||||
ToolTip="{l:Loc Tooltips.Editor.Workspace.KeepMine}" IsDefault="{Binding CanMerge, Mode=OneWay}" MinWidth="96" Margin="0,0,0,8"
|
||||
Visibility="{Binding CanMerge, Converter={StaticResource BoolToVisibility}}" />
|
||||
<!-- A conflict of format: Save both is the only choice that settles it. -->
|
||||
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Server.Sync.Action.SaveBoth}" Command="{Binding SaveBothCommand}" ToolTip="{Binding SaveBothToolTip}"
|
||||
IsDefault="{Binding IsNewerFormat, Mode=OneWay}" MinWidth="96" Margin="0,0,0,8"
|
||||
Visibility="{Binding CanMerge, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
|
||||
</WrapPanel>
|
||||
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" HorizontalAlignment="Right" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.IO;
|
||||
using Chronos.App.Editor;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Localization;
|
||||
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>
|
||||
/// Choosing another workspace folder (owner review 2, R8): Settings › Workspace › Change, and the refusal of a folder
|
||||
/// inside a library, where Edit cannot be used until one is chosen. The folder is picked, its plan shown and confirmed
|
||||
/// (the projects the folder in use keeps, those the new one holds), a workspace project open in the editor closes (its
|
||||
/// last edit stored first), and only then does the setting change. Nothing is moved or deleted: the projects of the
|
||||
/// folder left stay there, listed again once it is chosen back. Moving a workspace with its projects comes in phase 5c.
|
||||
/// </summary>
|
||||
public static class WorkspaceFolderChange
|
||||
{
|
||||
/// <summary>The shell's flow: its folder picker and confirmation, its editor, its toasts.</summary>
|
||||
public static async Task<bool> ChooseAsync(ShellViewModel shell)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shell);
|
||||
var changed = await ChooseAsync(shell.Services.Workspace, shell.Services.Dialogs, async () =>
|
||||
{
|
||||
if (shell.Sequence.Editor?.Session.Source is not WorkspaceSequenceSource) return true;
|
||||
if (!await shell.Sequence.ConfirmCloseAsync()) return false;
|
||||
await shell.Sequence.CloseAsync();
|
||||
shell.KeepSequence(null);
|
||||
return true;
|
||||
}, message => shell.Notify(Loc.L("Settings.Workspace.NotChanged"), message, isError: true));
|
||||
if (changed) shell.Notify(Loc.L("Settings.Workspace.Changed"), shell.Services.Workspace.Root);
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Picks a folder through <paramref name="dialogs"/>, confirms its plan, lets <paramref name="closeProject"/> close a
|
||||
/// workspace project open in the editor (false keeps everything as it is), then makes it the workspace's folder.
|
||||
/// <paramref name="failed"/> hears why a folder was refused. True when the folder changed.
|
||||
/// </summary>
|
||||
public static async Task<bool> ChooseAsync(WorkspaceHost host, IAppDialogs dialogs, Func<Task<bool>> closeProject, Action<string> failed)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(host);
|
||||
ArgumentNullException.ThrowIfNull(dialogs);
|
||||
ArgumentNullException.ThrowIfNull(closeProject);
|
||||
ArgumentNullException.ThrowIfNull(failed);
|
||||
if (dialogs.PickFolder(Loc.L("Settings.Workspace.ChooseTitle"), Directory.Exists(host.Root) ? host.Root : null) is not { } folder) return false;
|
||||
try
|
||||
{
|
||||
var plan = await host.PlanFolderAsync(folder);
|
||||
if (plan.IsSame) return false;
|
||||
if (plan.InsideLibrary)
|
||||
{
|
||||
failed(Loc.L("Errors.Workspace.InsideLibraryFolder", plan.Folder));
|
||||
return false;
|
||||
}
|
||||
if (!dialogs.Confirm(Request(plan))) return false;
|
||||
if (!await closeProject()) return false;
|
||||
await host.UseFolderAsync(plan.Folder);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArgumentException or WorkspaceException)
|
||||
{
|
||||
Log.Warning("workspace", $"The workspace folder was not changed to {folder}", ex);
|
||||
failed(ex is WorkspaceException ? ex.Message : Loc.L("Errors.Workspace.FolderUnusable", folder));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The plan as a confirmation: where Edit's projects come from now, and what stays where it is.</summary>
|
||||
public static ConfirmRequest Request(WorkspaceFolderPlan plan)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
return new ConfirmRequest
|
||||
{
|
||||
Heading = Loc.L("Settings.Workspace.ChangeTitle"),
|
||||
Message = Loc.L("Settings.Workspace.ChangeMessage", plan.Folder, plan.Current),
|
||||
Detail = string.Join(Environment.NewLine, Loc.L("Settings.Workspace.ProjectsLeft", Formatting.Count(plan.ProjectsLeft)),
|
||||
Loc.L("Settings.Workspace.ProjectsFound", Formatting.Count(plan.ProjectsFound))),
|
||||
IsDetailMonospaced = false,
|
||||
SafeText = Loc.L("Archive.Dialog.Cancel"),
|
||||
SafeToolTip = Loc.L("Tooltips.Settings.KeepWorkspace"),
|
||||
ActionText = Loc.L("Settings.Workspace.Use"),
|
||||
ActionToolTip = Loc.L("Tooltips.Settings.UseWorkspace"),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,39 @@ using Chronos.Data.Workspaces;
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>A workspace operation was refused for a reason the user can act on; the message is one localized sentence.</summary>
|
||||
public sealed class WorkspaceException(string message, Exception? inner = null) : InvalidOperationException(message, inner);
|
||||
public sealed class WorkspaceException(string message, Exception? inner = null) : InvalidOperationException(message, inner)
|
||||
{
|
||||
/// <summary>The workspace folder itself was refused (it lies inside a library): another folder is the way on (Settings › Workspace › Change).</summary>
|
||||
public bool FolderRefused { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>A project of this PC's workspace, as Edit's picker and the editor list it.</summary>
|
||||
/// <param name="HasMedia">The workspace holds the project's media (a copy that ended); without them it cannot open.</param>
|
||||
/// <param name="Saved">When its working state was last written.</param>
|
||||
/// <param name="Damaged">
|
||||
/// Its working state (<c>project.chronos</c>) cannot be read: listed by its folder, it cannot open, and Remove local copy
|
||||
/// can only keep its files aside in the workspace's trash (Discard).
|
||||
/// </param>
|
||||
public sealed record WorkspaceEntry(Guid ProjectId, Guid SequenceId, string Name, bool IsMain, BundleHome Home, string SequenceTitle, bool HasMedia,
|
||||
DateTimeOffset Saved);
|
||||
DateTimeOffset Saved, bool Damaged = false);
|
||||
|
||||
/// <summary>What changing the workspace folder to <see cref="Folder"/> does: Edit lists its projects from then on; nothing is moved.</summary>
|
||||
/// <param name="Current">The folder in use, whose projects stay where they are (listed again once it is chosen back).</param>
|
||||
/// <param name="ProjectsLeft">The projects the folder in use holds.</param>
|
||||
/// <param name="ProjectsFound">The projects <see cref="Folder"/> holds already (a workspace used before).</param>
|
||||
/// <param name="InsideLibrary">The folder lies inside a library: refused, as the copy would put its files among the library's.</param>
|
||||
public sealed record WorkspaceFolderPlan(string Current, string Folder, int ProjectsLeft, int ProjectsFound, bool InsideLibrary)
|
||||
{
|
||||
/// <summary>The folder chosen is the one in use: nothing to change.</summary>
|
||||
public bool IsSame => string.Equals(Path.TrimEndingDirectorySeparator(Current), Path.TrimEndingDirectorySeparator(Folder), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>What "Open in workspace" shows of the copy it queues: its bytes (as the copy reckons them) and the free bytes of the workspace's drive.</summary>
|
||||
public sealed record WorkspaceCopyFacts(long Bytes, long? Free)
|
||||
{
|
||||
/// <summary>The drive lacks the copy and the reserve the copy keeps: it would stop saying so.</summary>
|
||||
public bool TooLittleSpace => Free is { } free && free < Bytes + WorkspaceJobs.CopySpaceReserve;
|
||||
}
|
||||
|
||||
/// <summary>A project brought into the workspace and the copy of its media that was queued.</summary>
|
||||
public sealed record WorkspaceCheckout(SequenceProject Project, Job Copy);
|
||||
@@ -43,10 +69,12 @@ public sealed record WorkspaceHistory(IReadOnlyList<ProjectVersion> Versions, IR
|
||||
/// The home answered it no longer has the project or its sequence: nothing can be sent or checked there, so the copy can
|
||||
/// only go with its work kept aside (Discard).
|
||||
/// </param>
|
||||
public sealed record WorkspaceRemovalPlan(Guid ProjectId, string Name, int Files, long Bytes, int Unsent, bool Modified, bool Conflict, bool Offline, bool Gone = false)
|
||||
/// <param name="Damaged">The working state cannot be read: what it holds is not known, so the copy can only go with its files kept aside (Discard).</param>
|
||||
public sealed record WorkspaceRemovalPlan(Guid ProjectId, string Name, int Files, long Bytes, int Unsent, bool Modified, bool Conflict, bool Offline, bool Gone = false,
|
||||
bool Damaged = false)
|
||||
{
|
||||
/// <summary>Everything the copy holds is at the home: it can go without discarding anything.</summary>
|
||||
public bool IsSafe => Unsent == 0 && !Modified && !Conflict;
|
||||
public bool IsSafe => Unsent == 0 && !Modified && !Conflict && !Damaged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -147,33 +175,87 @@ public sealed class WorkspaceHost
|
||||
HomeOf(new BundleHome(BundleHome.ArchiveKind, sequenceId)) ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
|
||||
|
||||
/// <summary>
|
||||
/// The projects of the workspace (one whose working state cannot be read is left out, and logged). A workspace folder
|
||||
/// not made yet that lies inside a library is not made by listing it: it lists nothing.
|
||||
/// The projects of the workspace; one whose working state cannot be read is listed as damaged (<see cref="WorkspaceEntry.Damaged"/>),
|
||||
/// never hidden, and logged. A workspace folder not made yet that lies inside a library is not made by listing it: it lists nothing.
|
||||
/// </summary>
|
||||
public Task<IReadOnlyList<WorkspaceEntry>> ListAsync(CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
if (!Directory.Exists(Root) && await InsideALibraryAsync(cancellationToken).ConfigureAwait(false)) return [];
|
||||
return (IReadOnlyList<WorkspaceEntry>)[.. Store.ListBundles().Select(b => Entry(b.Project, b.Bundle))];
|
||||
return (IReadOnlyList<WorkspaceEntry>)[.. Store.List().Select(EntryOrDamaged)];
|
||||
}, cancellationToken);
|
||||
|
||||
/// <summary>The workspace projects of one sequence.</summary>
|
||||
public async Task<IReadOnlyList<WorkspaceEntry>> ProjectsOfAsync(Guid sequenceId, CancellationToken cancellationToken = default) =>
|
||||
[.. (await ListAsync(cancellationToken).ConfigureAwait(false)).Where(e => e.SequenceId == sequenceId)];
|
||||
|
||||
/// <summary>A workspace project by id; null when the workspace has none (or it cannot be read).</summary>
|
||||
/// <summary>A workspace project by id (damaged when its working state cannot be read); null when the workspace has none.</summary>
|
||||
public Task<WorkspaceEntry?> FindAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
if (!Directory.Exists(Root) && await InsideALibraryAsync(cancellationToken).ConfigureAwait(false)) return null;
|
||||
if (Store.Find(projectId) is not { } project) return null;
|
||||
try
|
||||
return Store.Find(projectId) is { } project ? EntryOrDamaged(project) : null;
|
||||
}, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// What changing the workspace folder to <paramref name="folder"/> would do (Settings › Workspace › Change, and the
|
||||
/// refusal of a folder inside a library): the projects the folder in use keeps where they are, those the new one holds
|
||||
/// already, and whether it lies inside a library. Nothing is written.
|
||||
/// </summary>
|
||||
public Task<WorkspaceFolderPlan> PlanFolderAsync(string folder, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(folder);
|
||||
var target = Path.GetFullPath(folder);
|
||||
return new WorkspaceFolderPlan(Root, target, CountProjects(Root), CountProjects(target), await InsideALibraryAsync(target, cancellationToken).ConfigureAwait(false));
|
||||
}, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Edit's workspace becomes <paramref name="folder"/> (made, with its manifest, when it is new): Settings › Workspace ›
|
||||
/// Folder names it from now on (none when it is the default). The projects of the folder left stay there, untouched.
|
||||
/// </summary>
|
||||
/// <exception cref="WorkspaceException">The folder lies inside a library (<see cref="WorkspaceException.FolderRefused"/>).</exception>
|
||||
/// <exception cref="IOException">The folder cannot be made or read.</exception>
|
||||
/// <exception cref="InvalidDataException">The folder holds another program's or a newer workspace manifest.</exception>
|
||||
public async Task UseFolderAsync(string folder, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var plan = await PlanFolderAsync(folder, cancellationToken).ConfigureAwait(false);
|
||||
if (plan.IsSame) return;
|
||||
if (plan.InsideLibrary) throw new WorkspaceException(Loc.L("Errors.Workspace.InsideLibraryFolder", plan.Folder)) { FolderRefused = true };
|
||||
// Opened before it is named: a folder that is no workspace is refused while the one in use still is.
|
||||
await Task.Run(() => new WorkspaceStore(plan.Folder), cancellationToken).ConfigureAwait(false);
|
||||
// Back on the caller's thread (the UI's): the settings are written there.
|
||||
_settings.WorkspaceFolder = string.Equals(plan.Folder, Path.GetFullPath(DefaultRoot(_environment)), StringComparison.OrdinalIgnoreCase) ? null : plan.Folder;
|
||||
_savePreferences();
|
||||
Log.Info("workspace", $"The workspace folder is now {plan.Folder} ({plan.ProjectsLeft} project(s) stay in {plan.Current})");
|
||||
}
|
||||
|
||||
/// <summary>The bytes the first copy of a sequence's media writes into the workspace, and the free bytes of the workspace's drive.</summary>
|
||||
/// <exception cref="WorkspaceException">The index or the archive engine is not open.</exception>
|
||||
public Task<WorkspaceCopyFacts> CopyFactsAsync(Guid sequenceId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var db = _db() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
|
||||
var archives = _archives() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
|
||||
var root = Root;
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
return Entry(project, project.ReadBundle());
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
var (bytes, free) = await WorkspaceJobs.CopyFactsAsync(db, archives, sequenceId, root, cancellationToken).ConfigureAwait(false);
|
||||
return new WorkspaceCopyFacts(bytes, free);
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A first copy of a project's media cancelled before it ended: the photos it wrote (copies the home can make again)
|
||||
/// are removed, so the workspace holds no half media. A project whose copy ended once keeps its media (Update media
|
||||
/// cancelled leaves the earlier ones in use). False when there was nothing to remove.
|
||||
/// </summary>
|
||||
public Task<bool> RemovePartialMediaAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
if (Store.Find(projectId) is not { } project) return false;
|
||||
using (await project.LockAsync(LockWait, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
Log.Warning("workspace", $"The project in {project.Folder} cannot be read", ex);
|
||||
return null;
|
||||
if (File.Exists(project.MediaIndexPath) || !Directory.Exists(project.MediaDirectory)) return false;
|
||||
Directory.Delete(project.MediaDirectory, recursive: true);
|
||||
}
|
||||
Log.Info("workspace", $"The media a cancelled first copy of project {projectId} wrote were removed");
|
||||
return true;
|
||||
}, cancellationToken);
|
||||
|
||||
/// <summary>The project of <paramref name="sequenceId"/> opened last here, else the one saved last; null when the workspace has none.</summary>
|
||||
@@ -214,7 +296,8 @@ public sealed class WorkspaceHost
|
||||
var checkout = await Task.Run(async () =>
|
||||
{
|
||||
// Refused before anything is written: the copy job would refuse such a folder after the checkout filled it.
|
||||
if (await InsideALibraryAsync(cancellationToken).ConfigureAwait(false)) throw new WorkspaceException(Loc.L("Errors.Workspace.InsideLibraryEdit", Root));
|
||||
if (await InsideALibraryAsync(cancellationToken).ConfigureAwait(false))
|
||||
throw new WorkspaceException(Loc.L("Errors.Workspace.InsideLibraryEdit", Root)) { FolderRefused = true };
|
||||
SequenceProject project;
|
||||
if (newName is not null)
|
||||
{
|
||||
@@ -505,6 +588,13 @@ public sealed class WorkspaceHost
|
||||
public Task<WorkspaceRemovalPlan> PlanRemovalAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
var project = Existing(projectId);
|
||||
if (EntryOrDamaged(project) is { Damaged: true } damaged)
|
||||
{
|
||||
// What it holds is not known: every version file not marked sent, or not readable, counts as unsent work, kept aside by Discard.
|
||||
var (count, size) = Measure(project.Folder);
|
||||
var unsent = project.Versions().Count(v => v.StoredAt is null) + project.UnreadableVersions().Count;
|
||||
return new WorkspaceRemovalPlan(projectId, damaged.Name, count, size, unsent, true, false, false, Damaged: true);
|
||||
}
|
||||
var name = project.ReadBundle().Workspace!.Name;
|
||||
var status = await StatusAsync(projectId, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
var (files, bytes) = Measure(project.Folder);
|
||||
@@ -524,6 +614,14 @@ public sealed class WorkspaceHost
|
||||
var sequenceId = await Task.Run(async () =>
|
||||
{
|
||||
var project = Existing(projectId);
|
||||
if (EntryOrDamaged(project) is { Damaged: true })
|
||||
{
|
||||
// Its working state cannot be read: only Discard, which keeps every file of it aside, takes it out.
|
||||
if (!discard) throw new WorkspaceException(Loc.L("Errors.Workspace.Damaged"));
|
||||
await RemoveFolderAsync(project, cancellationToken).ConfigureAwait(false);
|
||||
Log.Info("workspace", $"Damaged local copy of project {projectId} removed, its files kept in {TrashFolder}");
|
||||
return (Guid?)null;
|
||||
}
|
||||
var workspace = project.ReadBundle().Workspace!;
|
||||
if (!discard)
|
||||
{
|
||||
@@ -535,9 +633,9 @@ public sealed class WorkspaceHost
|
||||
}
|
||||
await RemoveFolderAsync(project, cancellationToken).ConfigureAwait(false);
|
||||
Log.Info("workspace", $"Local copy of project {projectId} ('{workspace.Name}') removed{(discard ? ", its unsent work kept in " + TrashFolder : string.Empty)}");
|
||||
return workspace.Home.SequenceId;
|
||||
return (Guid?)workspace.Home.SequenceId;
|
||||
}, cancellationToken);
|
||||
Forget(sequenceId, projectId);
|
||||
if (sequenceId is { } sequence) Forget(sequence, projectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -664,10 +762,12 @@ public sealed class WorkspaceHost
|
||||
/// The workspace folder lies inside a library this index knows (a portable copy's <c>data</c> folder under a library
|
||||
/// at a drive's root): editing happens outside every library, so nothing is checked out or copied there.
|
||||
/// </summary>
|
||||
private async Task<bool> InsideALibraryAsync(CancellationToken cancellationToken)
|
||||
private Task<bool> InsideALibraryAsync(CancellationToken cancellationToken) => InsideALibraryAsync(Root, cancellationToken);
|
||||
|
||||
private async Task<bool> InsideALibraryAsync(string folder, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_db() is not { } db) return false;
|
||||
var root = Plain(Path.GetFullPath(Root));
|
||||
var root = Plain(Path.GetFullPath(folder));
|
||||
foreach (var archive in await db.Archives.ListAsync(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (DataLocation.IsUnder(root, Plain(Path.GetFullPath(archive.RootPath)))) return true;
|
||||
@@ -717,6 +817,38 @@ public sealed class WorkspaceHost
|
||||
bundle.Sequence.Title is { Length: > 0 } title ? title : bundle.Sequence.Folder, File.Exists(project.MediaIndexPath), bundle.Saved);
|
||||
}
|
||||
|
||||
/// <summary>The project's entry; a damaged one, named by its folder, when its working state cannot be read (logged).</summary>
|
||||
private static WorkspaceEntry EntryOrDamaged(WorkspaceProject project)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Entry(project, project.ReadBundle());
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("workspace", $"The project in {project.Folder} cannot be read", ex);
|
||||
var saved = File.Exists(project.BundlePath) ? new DateTimeOffset(File.GetLastWriteTimeUtc(project.BundlePath), TimeSpan.Zero) : DateTimeOffset.MinValue;
|
||||
return new WorkspaceEntry(project.ProjectId, Guid.Empty, Path.GetFileName(project.Folder), false, new BundleHome(BundleHome.ArchiveKind, Guid.Empty),
|
||||
project.Folder, false, saved, Damaged: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The projects a workspace folder holds (folders named by a project id with a working state), without making or opening it.</summary>
|
||||
private static int CountProjects(string folder)
|
||||
{
|
||||
if (!Directory.Exists(folder)) return 0;
|
||||
try
|
||||
{
|
||||
return Directory.EnumerateDirectories(folder).Count(d => Guid.TryParseExact(Path.GetFileName(d), "N", out _)
|
||||
&& File.Exists(Path.Combine(d, WorkspaceProject.BundleFile)));
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Info("workspace", $"The projects of {folder} could not be counted: {ex.Message}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Files and bytes under <paramref name="folder"/>, the lease left out.</summary>
|
||||
private static (int Files, long Bytes) Measure(string folder)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>
|
||||
/// A project of the workspace in Edit's picker (owner review 2, R8): its name, its sequence (title and thumbnail) and
|
||||
/// where it stands, a chip read from its home after the list shows.
|
||||
/// where it stands, a chip read from its home after the list shows. A copy whose working state cannot be read is listed
|
||||
/// as damaged, by its folder.
|
||||
/// </summary>
|
||||
public sealed class WorkspaceProjectItem(WorkspaceEntry entry, SequenceItem? sequence) : ObservableObject
|
||||
{
|
||||
@@ -41,11 +42,16 @@ public sealed class WorkspaceProjectItem(WorkspaceEntry entry, SequenceItem? seq
|
||||
}
|
||||
}
|
||||
|
||||
public string StateText => Entry.HasMedia || _status is not null ? WorkspaceText.State(_status) : Loc.L("Editor.Workspace.State.MediaRemoved");
|
||||
/// <summary>Its working state cannot be read: it cannot open, and Remove local copy keeps its files aside.</summary>
|
||||
public bool IsDamaged => Entry.Damaged;
|
||||
|
||||
public StatusKind StateKind => Entry.HasMedia || _status is not null ? WorkspaceText.Kind(_status) : StatusKind.NoProxies;
|
||||
public string StateText => Entry.Damaged ? Loc.L("Editor.Workspace.State.Damaged")
|
||||
: Entry.HasMedia || _status is not null ? WorkspaceText.State(_status) : Loc.L("Editor.Workspace.State.MediaRemoved");
|
||||
|
||||
public string StateToolTip => Entry.HasMedia || _status is not null ? WorkspaceText.StateToolTip(_status) : Loc.L("Tooltips.Editor.Workspace.State.MediaRemoved");
|
||||
public StatusKind StateKind => Entry.Damaged ? StatusKind.Error : Entry.HasMedia || _status is not null ? WorkspaceText.Kind(_status) : StatusKind.NoProxies;
|
||||
|
||||
public string StateToolTip => Entry.Damaged ? Loc.L("Tooltips.Editor.Workspace.State.DamagedCopy")
|
||||
: Entry.HasMedia || _status is not null ? WorkspaceText.StateToolTip(_status) : Loc.L("Tooltips.Editor.Workspace.State.MediaRemoved");
|
||||
|
||||
/// <summary>"Vertical social · Harbour sunset · In sync": what screen readers hear for the row.</summary>
|
||||
public string Description => string.Join(Loc.Separator, Name, SequenceTitle, StateText);
|
||||
|
||||
@@ -72,9 +72,17 @@ public static class WorkspaceText
|
||||
/// <summary>"28/10/2026 18:02".</summary>
|
||||
public static string When(DateTimeOffset at) => $"{Formatting.Date(at)} {Formatting.TimeOfDay(at)}";
|
||||
|
||||
/// <summary>One line per setting both sides changed ("Deflicker window 41 here, 33 in the library"), at most <paramref name="max"/>.</summary>
|
||||
public static IReadOnlyList<string> ConflictLines(IEnumerable<SettingsDifference> differences, int max) =>
|
||||
SyncText.Differences(differences, max, (label, mine, theirs) => Loc.L("Editor.Workspace.Difference", label, mine, theirs));
|
||||
/// <summary>
|
||||
/// One line per setting both sides changed ("Deflicker window 41 here, 33 in the library"), at most <paramref name="max"/>.
|
||||
/// A conflict of format (<see cref="ProjectMerge.FormatPath"/>) reads as its cause, never as the format's numbers.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<string> ConflictLines(IEnumerable<SettingsDifference> differences, int max)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(differences);
|
||||
var list = differences.ToList();
|
||||
if (list.Any(d => d.Path == ProjectMerge.FormatPath)) return [Loc.L("Editor.Workspace.Conflict.NewerFormat")];
|
||||
return SyncText.Differences(list, max, (label, mine, theirs) => Loc.L("Editor.Workspace.Difference", label, mine, theirs));
|
||||
}
|
||||
|
||||
/// <summary>One line per setting that differs between now and a version ("Deflicker window 41 now, 33 in that version").</summary>
|
||||
public static IReadOnlyList<string> CompareLines(IEnumerable<SettingsDifference> differences, int max) =>
|
||||
@@ -84,6 +92,9 @@ public static class WorkspaceText
|
||||
public static string Failure(Exception ex) => ex switch
|
||||
{
|
||||
WorkspaceException or LeaseUnavailableException => ex.Message,
|
||||
// A library that can be read but not written (a read-only share, a write-protected disk): the work waits here as offline.
|
||||
HomeUnavailableException { InnerException: ArchiveOfflineException { Availability: ArchiveAvailability.ReadOnly } }
|
||||
or ArchiveOfflineException { Availability: ArchiveAvailability.ReadOnly } => Loc.L("Errors.Workspace.ReadOnlyHome"),
|
||||
HomeUnavailableException or ArchiveOfflineException => Loc.L("Errors.Workspace.Offline"),
|
||||
ProjectException { Reason: ProjectError.NameTaken } => Loc.L("Errors.Workspace.NameTaken"),
|
||||
ProjectException { Reason: ProjectError.InvalidName } => Loc.L("Errors.Workspace.InvalidName"),
|
||||
|
||||
@@ -35,6 +35,20 @@ public static class WorkspaceJobs
|
||||
/// parameters name).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<IJobHandler> CreateHandlers(ChronosDatabase db, ArchiveService archives) => [new WorkspaceCopyJobHandler(db, archives)];
|
||||
|
||||
/// <summary>
|
||||
/// What a first copy of a sequence's proxies writes into a workspace, as the copy reckons it before it starts (the
|
||||
/// archive's proxies' sizes, an estimate for those it makes), and the free bytes on <paramref name="workspaceRoot"/>'s
|
||||
/// drive (null when it cannot be measured): "Open in workspace" shows both. The copy keeps <see cref="CopySpaceReserve"/>
|
||||
/// free besides.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">The index has no such sequence or archive.</exception>
|
||||
public static Task<(long Bytes, long? Free)> CopyFactsAsync(ChronosDatabase db, ArchiveService archives, Guid sequenceId, string workspaceRoot,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
new WorkspaceCopyJobHandler(db, archives).FactsAsync(sequenceId, workspaceRoot, cancellationToken);
|
||||
|
||||
/// <summary>Bytes the copy leaves free on the workspace's drive besides what it copies.</summary>
|
||||
public static long CopySpaceReserve => WorkspaceCopyJobHandler.SpaceReserve;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,7 +76,7 @@ internal sealed class WorkspaceCopyJobHandler(ChronosDatabase db, ArchiveService
|
||||
private static readonly TimeSpan CheckpointEvery = TimeSpan.FromSeconds(5);
|
||||
|
||||
/// <summary>Bytes left free on the workspace's drive besides the copy, as a download keeps (<see cref="SyncTransfers"/>).</summary>
|
||||
private const long SpaceReserve = 512L << 20;
|
||||
internal const long SpaceReserve = 512L << 20;
|
||||
|
||||
/// <summary>A proxy at <see cref="ProxyEstimateEdge"/> px, when the archive has none to measure: some 1.5 MB.</summary>
|
||||
private const long ProxyEstimate = 3L << 19;
|
||||
@@ -364,11 +378,13 @@ internal sealed class WorkspaceCopyJobHandler(ChronosDatabase db, ArchiveService
|
||||
/// nothing for a frame the workspace holds a file of already (kept, or replaced by one of about its size), the archive's
|
||||
/// proxy's size where it has one, else an estimate at the proxy size the copy makes (<see cref="Estimate"/>).
|
||||
/// </summary>
|
||||
private static long[] Remaining(WorkspaceProject project, SequencePaths folder, List<Frame> frames, ProxyPolicy policy)
|
||||
{
|
||||
var held = Directory.Exists(project.ProxiesDirectory)
|
||||
private static long[] Remaining(WorkspaceProject project, SequencePaths folder, List<Frame> frames, ProxyPolicy policy) =>
|
||||
Remaining(Directory.Exists(project.ProxiesDirectory)
|
||||
? Directory.EnumerateFiles(project.ProxiesDirectory).Select(Path.GetFileName).ToHashSet(StringComparer.OrdinalIgnoreCase)
|
||||
: [];
|
||||
: [], folder, frames, policy);
|
||||
|
||||
private static long[] Remaining(HashSet<string?> held, SequencePaths folder, List<Frame> frames, ProxyPolicy policy)
|
||||
{
|
||||
var proxies = Directory.Exists(folder.Proxies)
|
||||
? new DirectoryInfo(folder.Proxies).EnumerateFiles().ToDictionary(f => f.Name, f => f.Length, StringComparer.OrdinalIgnoreCase)
|
||||
: [];
|
||||
@@ -385,6 +401,17 @@ internal sealed class WorkspaceCopyJobHandler(ChronosDatabase db, ArchiveService
|
||||
return remaining;
|
||||
}
|
||||
|
||||
/// <summary>What a first copy of the sequence writes (nothing held yet), and the free bytes of the workspace's drive.</summary>
|
||||
internal async Task<(long Bytes, long? Free)> FactsAsync(Guid sequenceId, string workspaceRoot, CancellationToken cancellationToken)
|
||||
{
|
||||
var (row, frames) = await FramesAsync(sequenceId, cancellationToken).ConfigureAwait(false);
|
||||
var archive = await db.Archives.GetAsync(row.ArchiveId, cancellationToken).ConfigureAwait(false)
|
||||
?? throw new InvalidOperationException(Loc.L("Archive.Log.SequenceMissing", sequenceId));
|
||||
var paths = new ArchivePaths(archive.RootPath);
|
||||
var policy = ManifestStore.ReadArchive(paths.ManifestPath).ProxyPolicy;
|
||||
return (Remaining([], paths.Sequence(row.Folder), frames, policy)[0], FreeBytes(workspaceRoot));
|
||||
}
|
||||
|
||||
/// <summary>A proxy's size when the archive has none to measure: some 1.5 MB at 1920 px, scaled by the area at the copy's long edge.</summary>
|
||||
private static long Estimate(Frame frame, ProxyPolicy policy)
|
||||
{
|
||||
|
||||
@@ -419,6 +419,16 @@ public sealed class WorkspaceProject
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a version straight into <c>versions/.replaced</c>: kept, never part of the chain of versions to send (the
|
||||
/// working state a take of the server's values replaced).
|
||||
/// </summary>
|
||||
internal void WriteAside(ProjectVersion version)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(version);
|
||||
ProjectSidecars.WriteVersion(Path.Combine(VersionsDirectory, ReplacedFolder, Path.GetFileName(VersionPath(version))), version);
|
||||
}
|
||||
|
||||
/// <summary>Moves tried, some 1 s in all, before a version file held open fails to move aside.</summary>
|
||||
private const int SetAsideAttempts = 15;
|
||||
|
||||
|
||||
@@ -125,8 +125,9 @@ public sealed class WorkspaceSyncException(PushOutcome outcome, string message)
|
||||
/// (hashed or converted there since the copy), so every side names one photo alike. Settings of a newer Chronos are never
|
||||
/// merged with this one's: a project with nothing of its own moves onto them read-only, any other waits on a conflict of
|
||||
/// format that only Save both settles (<see cref="WorkspaceConflict.NewerFormat"/>). Every operation holds the project's
|
||||
/// lease; nothing is ever deleted: a restore, a save-both or taking the server's values first saves uncommitted changes as
|
||||
/// a version.
|
||||
/// lease; nothing is ever deleted: a restore or a save-both first saves uncommitted changes as a version, and taking the
|
||||
/// server's values keeps the working state they replace aside (<c>versions/.replaced</c>). A conflict lists this side's
|
||||
/// values as the working state holds them, so it is asked and settled against what the user sees.
|
||||
/// Every write sequence survives a cut at any step: the working state's base is the commit point. A push moves the base
|
||||
/// before its local file reads as sent; a replay journals itself in <c>sync.json</c> (<see cref="WorkspaceReplay"/>), writes
|
||||
/// the replayed versions, then the base, and only then sets the old ones aside; a save-both journals its copy and the ids
|
||||
@@ -348,10 +349,10 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
/// either way the local versions are replayed on the home's head and wait to be pushed. A choice applies only to the
|
||||
/// conflicts listed: when what differs now is not that (the home moved on, or this side was edited meanwhile), nothing
|
||||
/// is settled, and the conflict found now is recorded and returned to be asked again; so is one the home holds no
|
||||
/// versions for now (nothing to take them from). Taking the server's first saves uncommitted changes as a version, so
|
||||
/// the values it replaces are kept (its file in <c>versions/.replaced</c>); replayed, that version holds the server's
|
||||
/// values only and is not sent. After a Save both cut short, either choice first sends the rest of this workspace's
|
||||
/// versions to the copy it made (one somebody else pushed to since is left as it is).
|
||||
/// versions for now (nothing to take them from). Taking the server's keeps the working state it replaces as a version
|
||||
/// file in <c>versions/.replaced</c>, outside the chain: nothing is committed, replayed or sent for it, so a take that
|
||||
/// leaves only the server's values sends nothing. After a Save both cut short, either choice first sends the rest of
|
||||
/// this workspace's versions to the copy it made (one somebody else pushed to since is left as it is).
|
||||
/// <see cref="ConflictChoice.SaveBoth"/> saves the working state as a version, sends this workspace's versions to a new
|
||||
/// project at the home (<paramref name="saveBothName"/>, else this project's name with a number) made from the base,
|
||||
/// and moves this project onto the home's head.
|
||||
@@ -371,12 +372,11 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
EnsureChained(project, bundle, Unpushed(project, bundle));
|
||||
if (choice == ConflictChoice.SaveBoth)
|
||||
return await SaveBothAsync(project, bundle, home, saveBothName, cancellationToken).ConfigureAwait(false);
|
||||
// A conflict of format refuses the choice (nothing is merged with a newer Chronos's settings): nothing is saved first.
|
||||
var saved = choice == ConflictChoice.TakeServer && !bundle.IsReadOnly && !recorded.NewerFormat ? CommitLocked(project, bundle, null, null) : null;
|
||||
// Nothing is committed first: a version of the working state would be replayed into one that only repeats the
|
||||
// head, and sent. What the take replaces of the working state is kept aside by the replay instead.
|
||||
IReadOnlySet<string> takeTheirs = choice == ConflictChoice.TakeServer ? AllPaths : takeServer ?? new HashSet<string>();
|
||||
ProjectSettings? kept = null;
|
||||
var (_, conflict, pulled) = await ReplayAsync(project, project.ReadBundle(), home, takeTheirs, cancellationToken, shown ?? recorded, k => kept = k, saved?.Id)
|
||||
.ConfigureAwait(false);
|
||||
var (_, conflict, pulled) = await ReplayAsync(project, bundle, home, takeTheirs, cancellationToken, shown ?? recorded, k => kept = k).ConfigureAwait(false);
|
||||
if (conflict is null) project.WriteSync(project.ReadSync() with { Conflict = null });
|
||||
return new WorkspaceSyncResult(await StatusLockedAsync(project, home, cancellationToken).ConfigureAwait(false), [], pulled)
|
||||
{
|
||||
@@ -445,16 +445,16 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
/// files; the base only moves onto local commits the home already holds); with a choice the conflicts are settled by it,
|
||||
/// only when they are those <paramref name="shown"/> lists (others are recorded and asked about first, as without a
|
||||
/// choice). Taking the server's everywhere tells <paramref name="kept"/> the working state as keeping this side's values
|
||||
/// would have left it (placed); <paramref name="saved"/> names the version taking them saved first, which is not replayed
|
||||
/// when it then holds nothing its parent does not (its file is set aside with the others, for the undo). A conflict
|
||||
/// recorded before stays when the home holds no version after the base (it lost them: nothing to settle it against).
|
||||
/// would have left it (placed), and the working state it replaces is kept aside (<c>versions/.replaced</c>), never in the
|
||||
/// chain. A conflict recorded before stays when the home holds no version after the base (it lost them: nothing to
|
||||
/// settle it against).
|
||||
/// Written in steps a cut can stop at any point (<see cref="WorkspaceReplay"/>): the journal, the replayed versions, the
|
||||
/// base with the merged working state (the commit point), then the old versions set aside and the held ones adopted.
|
||||
/// Before the commit point the rest of a Save both cut short goes to its copy (<see cref="FinishCopyAsync"/>).
|
||||
/// </summary>
|
||||
private async Task<(ProjectBundle Bundle, WorkspaceConflict? Conflict, IReadOnlyList<ProjectVersion> Pulled)> ReplayAsync(WorkspaceProject project,
|
||||
ProjectBundle bundle, IProjectHome home, IReadOnlySet<string>? takeTheirs, CancellationToken cancellationToken, WorkspaceConflict? shown = null,
|
||||
Action<ProjectSettings>? kept = null, Guid? saved = null)
|
||||
Action<ProjectSettings>? kept = null)
|
||||
{
|
||||
var basis = await BaseVersionAsync(project, bundle, home, cancellationToken).ConfigureAwait(false);
|
||||
// A local commit the home stored although its answer was lost comes back among the home's versions, and the commits
|
||||
@@ -507,7 +507,8 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var merge = ProjectMerge.MergeWithConflicts(tip, working, newTip, choice);
|
||||
var keptMine = takeTheirs is EveryPath ? ProjectMerge.MergeWithConflicts(tip, working, keptTip).Merged : merge.Merged;
|
||||
if (takeTheirs is EveryPath) merge = ProjectMerge.MergeWithConflicts(tip, working, newTip, Paths(merge.Conflicts));
|
||||
var differences = replay.Conflicts.Concat(merge.Conflicts).DistinctBy(d => d.Path).ToList();
|
||||
var differences = AsInTheWorkingState(replay.Conflicts.Concat(merge.Conflicts).DistinctBy(d => d.Path),
|
||||
ProjectMerge.Conflicts(basisSettings, working, headSettings));
|
||||
if (differences.Count > 0 && (takeTheirs is null || (shown is not null && !SameDifferences(shown.Differences, differences))))
|
||||
{
|
||||
var conflict = new WorkspaceConflict(head.Id, head.Number, basis?.Id ?? Guid.Empty, [.. locals.Select(v => v.Id)], differences, DateTimeOffset.UtcNow);
|
||||
@@ -517,12 +518,9 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
}
|
||||
var rebased = new List<ProjectVersion>(locals.Count);
|
||||
ProjectVersion parent = head;
|
||||
var previous = headSettings;
|
||||
for (var i = 0; i < locals.Count; i++)
|
||||
{
|
||||
var local = locals[i];
|
||||
// The version taking the server's saved first, replayed onto their values, holds nothing more: not sent (kept aside for the undo).
|
||||
if (local.Id == saved && ProjectMerge.SameValues(replay.Commits[i], previous)) continue;
|
||||
var portable = ProjectContent.Canonical(replay.Commits[i].ToJson());
|
||||
parent = local with
|
||||
{
|
||||
@@ -535,12 +533,15 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
StoredAt = null,
|
||||
};
|
||||
rebased.Add(parent);
|
||||
previous = replay.Commits[i];
|
||||
}
|
||||
if (differences.Count > 0 && rebased.Count > 0) rebased[^1] = rebased[^1] with { Kind = ProjectVersionKind.Merge };
|
||||
var placed = ProjectSettings.FromJson(ProjectContent.Place(ProjectContent.Canonical(merge.Merged.ToJson()), photos), allowNewer: true);
|
||||
var moved = WithBase(bundle, head) with { Project = placed, Saved = DateTimeOffset.UtcNow };
|
||||
await FinishCopyAsync(project, home, chain, cancellationToken).ConfigureAwait(false);
|
||||
// Taking the server's values over changes no version holds yet: the working state is kept aside first, never in the chain.
|
||||
if (takeTheirs is EveryPath && differences.Count > 0 && Portable(bundle.Project, media) is { } unsaved
|
||||
&& (tipVersion is null || !ProjectContent.SameChoices(tipVersion.SettingsJson, unsaved, photos)))
|
||||
project.WriteAside(VersionOf(project, unsaved, tipVersion, ProjectVersionKind.Commit, null, null, null, media?.FramesVersion ?? bundle.Workspace!.Media.FramesVersion));
|
||||
var journal = new WorkspaceReplay(head.Id, [.. locals.Select(v => v.Id)], [.. rebased.Select(v => v.Id)], [.. held.Select(v => v.Id)]);
|
||||
project.WriteSync(project.ReadSync() with { Replay = journal });
|
||||
Step("replay.journal");
|
||||
@@ -920,28 +921,37 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var restoredFrom = sync.RestoredFrom is { } restored && StillRestores(project, restored, Tip(project, bundle, locals), portable, media?.Photos ?? NoFrames)
|
||||
? sync.RestoredFrom
|
||||
: null;
|
||||
var version = new ProjectVersion
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
ProjectId = project.ProjectId,
|
||||
ParentId = tipId,
|
||||
Number = tipNumber + 1,
|
||||
Kind = restoredFrom is null ? ProjectVersionKind.Commit : ProjectVersionKind.Restore,
|
||||
Author = author,
|
||||
ClientName = clientName,
|
||||
Note = string.IsNullOrWhiteSpace(note) ? null : note.Trim(),
|
||||
SettingsJson = portable,
|
||||
ContentHash = hash,
|
||||
SettingsFormat = ProjectContent.FormatOf(portable),
|
||||
FramesVersion = media?.FramesVersion ?? workspace.Media.FramesVersion,
|
||||
RestoredFrom = restoredFrom,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
var version = VersionOf(project, portable, (tipId, tipNumber), restoredFrom is null ? ProjectVersionKind.Commit : ProjectVersionKind.Restore, note, author,
|
||||
restoredFrom, media?.FramesVersion ?? workspace.Media.FramesVersion);
|
||||
project.WriteVersion(version);
|
||||
if (sync.RestoredFrom is not null) project.WriteSync(sync with { RestoredFrom = null });
|
||||
return version;
|
||||
}
|
||||
|
||||
/// <summary>A version of this workspace holding <paramref name="portable"/>, the child of <paramref name="parent"/> (null: the first).</summary>
|
||||
private ProjectVersion VersionOf(WorkspaceProject project, string portable, ProjectVersion? parent, ProjectVersionKind kind, string? note, string? author,
|
||||
Guid? restoredFrom, int framesVersion) =>
|
||||
VersionOf(project, portable, (parent?.Id, parent?.Number ?? 0), kind, note, author, restoredFrom, framesVersion);
|
||||
|
||||
private ProjectVersion VersionOf(WorkspaceProject project, string portable, (Guid? Id, int Number) parent, ProjectVersionKind kind, string? note, string? author,
|
||||
Guid? restoredFrom, int framesVersion) => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
ProjectId = project.ProjectId,
|
||||
ParentId = parent.Id,
|
||||
Number = parent.Number + 1,
|
||||
Kind = kind,
|
||||
Author = author,
|
||||
ClientName = clientName,
|
||||
Note = string.IsNullOrWhiteSpace(note) ? null : note.Trim(),
|
||||
SettingsJson = portable,
|
||||
ContentHash = ProjectContent.Hash(portable),
|
||||
SettingsFormat = ProjectContent.FormatOf(portable),
|
||||
FramesVersion = framesVersion,
|
||||
RestoredFrom = restoredFrom,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Where the project stands. With a <paramref name="home"/>, the media first learn how it names its photos now (a photo
|
||||
/// hashed or converted there since the copy, <see cref="WorkspaceMedia.NamedAsAt"/>), so a version the home made since
|
||||
@@ -1099,6 +1109,17 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
return merge.Conflicts.Count == 0 && ProjectContent.Canonical(merge.Merged.ToJson()) == ProjectContent.Canonical(now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The conflicts found as the user sees them: where the working state holds a value of its own against the home's
|
||||
/// (<paramref name="working"/>: edited since the last local version), that value is this side's, not the version's.
|
||||
/// Keeping mine keeps it, and taking the server's replaces it, so one answer settles what was listed.
|
||||
/// </summary>
|
||||
private static List<SettingsDifference> AsInTheWorkingState(IEnumerable<SettingsDifference> found, IReadOnlyList<SettingsDifference> working)
|
||||
{
|
||||
var now = working.DistinctBy(d => d.Path).ToDictionary(d => d.Path, StringComparer.Ordinal);
|
||||
return [.. found.Select(d => now.TryGetValue(d.Path, out var held) ? held : d)];
|
||||
}
|
||||
|
||||
/// <summary>Whether two conflicts list the same settings with the same values on each side (in any order).</summary>
|
||||
private static bool SameDifferences(IReadOnlyList<SettingsDifference> shown, IReadOnlyList<SettingsDifference> found) =>
|
||||
shown.Count == found.Count && shown.ToHashSet().SetEquals(found);
|
||||
|
||||
@@ -153,6 +153,27 @@ public sealed class SyncTextTests
|
||||
Assert.Equal(0, rows.Count(r => SyncText.Matches(r, SyncFilter.Conflicts, "comet")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ASettingDifferingOnSeveralPhotosIsOneLineWithTheirCount()
|
||||
{
|
||||
var keyframes = new SettingsDifference("pendingFrames.sha:ab12#0.keyframes", "[]", "[{\"x\":1}]");
|
||||
var lines = SyncText.Differences(
|
||||
[
|
||||
new SettingsDifference("pendingFrames.sha:ab12#0.excluded", "true", "false"),
|
||||
keyframes,
|
||||
new SettingsDifference("pendingFrames.sha:cd34#0.excluded", "true", "false"),
|
||||
new SettingsDifference("pendingFrames.sha:ef56#1.excluded", "false", "true"),
|
||||
new SettingsDifference("pendingFrames.sha:ab12#0.excluded", "true", "false"),
|
||||
], 10);
|
||||
// Counted by photo, in the order the settings were met; a setting on one photo keeps its values.
|
||||
Assert.SequenceEqual(
|
||||
[Loc.L("Server.Conflict.Count", Loc.L("Server.Setting.ExcludedFrames"), Chronos.App.Infrastructure.Formatting.Count(3)), SyncText.Differences([keyframes], 1)[0]],
|
||||
lines);
|
||||
Assert.Contains(Loc.L("Server.Setting.Keyframes"), lines[1]);
|
||||
Assert.Count(1, SyncText.Differences([new SettingsDifference("pendingFrames.sha:ab12#0.excluded", "true", "false")], 10));
|
||||
Assert.Contains(Loc.L("Server.Setting.ExcludedFrames"), SyncText.Differences([new SettingsDifference("pendingFrames.sha:ab12#0.excluded", "true", "false")], 10)[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ATransferCountsWhereItsOriginalsAre()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,319 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Chronos.App.Archiving;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.App.Workspace;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Data.Workspaces;
|
||||
using Chronos.Testing;
|
||||
using Chronos.Ui.Controls;
|
||||
|
||||
namespace Chronos.App.Tests.Workspace;
|
||||
|
||||
/// <summary>
|
||||
/// The ways on that review 2's phase 5a fix round 2 gave the workspace (owner review 2, R8): another workspace folder when
|
||||
/// the one in use is refused, a copy whose working state cannot be read listed as damaged and removed only after a plan,
|
||||
/// the half media of a cancelled first copy, the copy's size and the drive's free space before it starts, a conflict of
|
||||
/// format that offers only Save both, a read-only library named as such, and pruning that keeps a version the library
|
||||
/// cannot give back.
|
||||
/// </summary>
|
||||
[Category("workspace")]
|
||||
public sealed class WorkspaceFallbackTests(TestContext context)
|
||||
{
|
||||
static WorkspaceFallbackTests() => Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
|
||||
[Test]
|
||||
public async Task AnotherWorkspaceFolderIsUsedAfterItsPlanAndNothingIsMoved()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var settings = new AppSettings();
|
||||
var saves = 0;
|
||||
var host = new WorkspaceHost(bed.Environment, settings, () => saves++, () => bed.Db, () => bed.Archives, () => bed.Engine)
|
||||
{
|
||||
LockWait = TimeSpan.FromSeconds(TestTiming.Budget(10)),
|
||||
};
|
||||
var mainId = await bed.CheckoutAsync(host);
|
||||
var first = host.Root;
|
||||
var before = saves;
|
||||
var row = await bed.RowAsync();
|
||||
var library = (await bed.Db.Archives.GetAsync(row.ArchiveId))!.RootPath;
|
||||
|
||||
// A folder inside a library is refused, and nothing changes.
|
||||
var inside = Path.Combine(library, "workspace");
|
||||
Assert.True((await host.PlanFolderAsync(inside)).InsideLibrary);
|
||||
var refused = await Assert.ThrowsAsync<WorkspaceException>(() => host.UseFolderAsync(inside));
|
||||
Assert.True(refused.FolderRefused);
|
||||
Assert.Equal(Loc.L("Errors.Workspace.InsideLibraryFolder", Path.GetFullPath(inside)), refused.Message);
|
||||
Assert.Equal(((string?)null, before, first), (settings.WorkspaceFolder, saves, host.Root));
|
||||
Assert.False(Directory.Exists(inside), "nothing was written there");
|
||||
|
||||
// The plan counts what stays and what is found; using the folder names it in the settings and lists its projects.
|
||||
var other = Path.Combine(bed.Directory, "other workspace");
|
||||
var plan = await host.PlanFolderAsync(other);
|
||||
Assert.Equal(new WorkspaceFolderPlan(first, Path.GetFullPath(other), 1, 0, false), plan);
|
||||
Assert.False(plan.IsSame);
|
||||
Assert.True((await host.PlanFolderAsync(first + Path.DirectorySeparatorChar)).IsSame);
|
||||
await host.UseFolderAsync(other);
|
||||
Assert.Equal((Path.GetFullPath(other), before + 1), (settings.WorkspaceFolder, saves));
|
||||
Assert.Equal(Path.GetFullPath(other), host.Root);
|
||||
Assert.Empty(await host.ListAsync());
|
||||
Assert.FileExists(Path.Combine(first, mainId.ToString("N"), WorkspaceProject.BundleFile));
|
||||
|
||||
// Chosen back, the default is named by no setting and its project is listed again.
|
||||
Assert.Equal(new WorkspaceFolderPlan(Path.GetFullPath(other), first, 0, 1, false), await host.PlanFolderAsync(first));
|
||||
await host.UseFolderAsync(first);
|
||||
Assert.Equal(((string?)null, before + 2), (settings.WorkspaceFolder, saves));
|
||||
Assert.Equal(mainId, (await host.ListAsync()).Single().ProjectId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ChoosingAFolderAsksItsPlanAndClosesTheProjectFirst()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var settings = new AppSettings();
|
||||
var host = bed.Host(settings);
|
||||
await bed.CheckoutAsync(host);
|
||||
var first = host.Root;
|
||||
var library = (await bed.Db.Archives.GetAsync((await bed.RowAsync()).ArchiveId))!.RootPath;
|
||||
var failures = new List<string>();
|
||||
var closes = 0;
|
||||
var close = true;
|
||||
Task<bool> CloseProject()
|
||||
{
|
||||
closes++;
|
||||
return Task.FromResult(close);
|
||||
}
|
||||
|
||||
// Nothing picked, or the folder in use: nothing asked.
|
||||
var dialogs = new ScriptedDialogs { Folder = null };
|
||||
Assert.False(await WorkspaceFolderChange.ChooseAsync(host, dialogs, CloseProject, failures.Add));
|
||||
dialogs.Folder = first;
|
||||
Assert.False(await WorkspaceFolderChange.ChooseAsync(host, dialogs, CloseProject, failures.Add));
|
||||
Assert.Empty(dialogs.Asked);
|
||||
|
||||
// Inside a library: refused with why, without asking.
|
||||
dialogs.Folder = Path.Combine(library, "inside");
|
||||
Assert.False(await WorkspaceFolderChange.ChooseAsync(host, dialogs, CloseProject, failures.Add));
|
||||
Assert.SequenceEqual([Loc.L("Errors.Workspace.InsideLibraryFolder", Path.GetFullPath(dialogs.Folder!))], failures);
|
||||
Assert.Empty(dialogs.Asked);
|
||||
|
||||
// Declined, or the open project kept open: the folder stays.
|
||||
var other = Path.Combine(bed.Directory, "elsewhere");
|
||||
dialogs.Folder = other;
|
||||
dialogs.Answer = false;
|
||||
Assert.False(await WorkspaceFolderChange.ChooseAsync(host, dialogs, CloseProject, failures.Add));
|
||||
Assert.Count(1, dialogs.Asked);
|
||||
var asked = dialogs.Asked[0];
|
||||
Assert.Equal(Loc.L("Settings.Workspace.ChangeMessage", Path.GetFullPath(other), first), asked.Message);
|
||||
Assert.Contains(Loc.L("Settings.Workspace.ProjectsLeft", Formatting.Count(1)), asked.Detail);
|
||||
Assert.Contains(Loc.L("Settings.Workspace.ProjectsFound", Formatting.Count(0)), asked.Detail);
|
||||
Assert.True(asked is { IsDestructive: false, ActionText.Length: > 0, ActionToolTip.Length: > 0, SafeToolTip.Length: > 0 });
|
||||
Assert.Equal(0, closes, "nothing closed before the plan is confirmed");
|
||||
dialogs.Answer = true;
|
||||
close = false;
|
||||
Assert.False(await WorkspaceFolderChange.ChooseAsync(host, dialogs, CloseProject, failures.Add));
|
||||
Assert.Equal((1, first), (closes, host.Root));
|
||||
|
||||
close = true;
|
||||
Assert.True(await WorkspaceFolderChange.ChooseAsync(host, dialogs, CloseProject, failures.Add));
|
||||
Assert.Equal((Path.GetFullPath(other), 2), (host.Root, closes));
|
||||
Assert.Count(1, failures);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SettingsWorkspaceChangesTheFolderOnlyWhereItCan()
|
||||
{
|
||||
var settings = new AppSettings();
|
||||
var changes = 0;
|
||||
var rows = new WorkspaceSettingsRows(settings, () => { }, () => @"D:\Workspace", () => { }, () =>
|
||||
{
|
||||
changes++;
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
Assert.True(rows.CanChange && rows.ChangeCommand.CanExecute(null));
|
||||
rows.ChangeCommand.Execute(null);
|
||||
Assert.Equal(1, changes);
|
||||
var capture = new WorkspaceSettingsRows(settings, () => { }, () => @"D:\Workspace", () => { });
|
||||
Assert.False(capture.CanChange || capture.ChangeCommand.CanExecute(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ACopyWhoseWorkingStateCannotBeReadIsListedAsDamagedAndGoesOnlyByDiscard()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var host = bed.Host(new AppSettings { WorkspaceAutoSync = false });
|
||||
var mainId = await bed.CheckoutAsync(host);
|
||||
var (_, session) = await bed.OpenAsync(host, mainId);
|
||||
await using (session)
|
||||
{
|
||||
session.Edit(p => p with { HeroFrame = 2 });
|
||||
Assert.True(await session.FlushAsync());
|
||||
}
|
||||
var unsent = (await host.SaveVersionAsync(mainId, "Not sent")).Version!;
|
||||
var project = host.Store.Find(mainId)!;
|
||||
await File.WriteAllTextAsync(project.BundlePath, "{ this is not a project", bed.Ct);
|
||||
|
||||
var all = await host.ListAsync();
|
||||
Assert.Count(1, all);
|
||||
var listed = all[0];
|
||||
Assert.True(listed is { Damaged: true, HasMedia: false });
|
||||
Assert.Equal(mainId, listed.ProjectId);
|
||||
Assert.True((await host.FindAsync(mainId))!.Damaged);
|
||||
Assert.Empty(await host.ProjectsOfAsync(bed.SequenceId), "a copy that cannot say its sequence is not one of it");
|
||||
var item = new WorkspaceProjectItem(listed, null);
|
||||
Assert.Equal((Loc.L("Editor.Workspace.State.Damaged"), StatusKind.Error, Loc.L("Tooltips.Editor.Workspace.State.DamagedCopy")),
|
||||
(item.StateText, item.StateKind, item.StateToolTip));
|
||||
|
||||
var plan = await host.PlanRemovalAsync(mainId);
|
||||
Assert.True(plan is { Damaged: true, IsSafe: false, Unsent: 1 });
|
||||
Assert.Greater(plan.Files, 0);
|
||||
var dialog = new RemoveCopyDialogViewModel(plan, _ => Task.CompletedTask, () => Task.CompletedTask, () => false, _ => { });
|
||||
Assert.False(dialog.RemoveCommand.CanExecute(null) || dialog.SendFirstCommand.CanExecute(null));
|
||||
Assert.True(dialog.DiscardCommand.CanExecute(null));
|
||||
Assert.Equal((Loc.L("Errors.Workspace.Damaged"), Loc.L("Errors.Workspace.Damaged")), (dialog.RemoveToolTip, dialog.SendFirstToolTip));
|
||||
|
||||
var refused = await Assert.ThrowsAsync<WorkspaceException>(() => host.RemoveLocalCopyAsync(mainId, discard: false));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.Damaged"), refused.Message);
|
||||
Assert.NotNull(host.Store.Find(mainId), "nothing was removed");
|
||||
|
||||
await host.RemoveLocalCopyAsync(mainId, discard: true);
|
||||
Assert.Null(host.Store.Find(mainId));
|
||||
var aside = Assert.Contains(Directory.EnumerateDirectories(Path.Combine(host.Root, WorkspaceHost.TrashFolder)),
|
||||
d => Path.GetFileName(d).StartsWith(mainId.ToString("N"), StringComparison.Ordinal));
|
||||
Assert.Equal("{ this is not a project", await File.ReadAllTextAsync(Path.Combine(aside, WorkspaceProject.BundleFile), bed.Ct), "kept as it was");
|
||||
Assert.True(Directory.EnumerateFiles(Path.Combine(aside, WorkspaceProject.VersionsFolder)).Any(f => f.Contains(unsent.Id.ToString(), StringComparison.OrdinalIgnoreCase)
|
||||
|| f.Contains(unsent.Id.ToString("N"), StringComparison.OrdinalIgnoreCase)), "the version never sent is kept");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ACancelledFirstCopyLeavesNoHalfMedia()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var host = bed.Host();
|
||||
var mainId = await bed.CheckoutAsync(host);
|
||||
var project = host.Store.Find(mainId)!;
|
||||
Assert.False(await host.RemovePartialMediaAsync(mainId), "a copy that ended keeps its media");
|
||||
Assert.FileExists(project.MediaIndexPath);
|
||||
|
||||
// A first copy stopped before its index was written: what it wrote goes, the working state stays.
|
||||
File.Delete(project.MediaIndexPath);
|
||||
Assert.NotEmpty(Directory.EnumerateFiles(project.MediaDirectory, "*", SearchOption.AllDirectories));
|
||||
Assert.True(await host.RemovePartialMediaAsync(mainId));
|
||||
Assert.False(Directory.Exists(project.MediaDirectory));
|
||||
Assert.FileExists(project.BundlePath);
|
||||
Assert.False(await host.RemovePartialMediaAsync(mainId), "nothing left to remove");
|
||||
Assert.False(await host.RemovePartialMediaAsync(Guid.NewGuid()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task OpenInWorkspaceShowsTheCopysSizeAndTheFreeSpace()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var host = bed.Host();
|
||||
var facts = await host.CopyFactsAsync(bed.SequenceId);
|
||||
Assert.Greater(facts.Bytes, 0);
|
||||
Assert.NotNull(facts.Free);
|
||||
Assert.False(facts.TooLittleSpace, "the test drive has room for four small proxies");
|
||||
|
||||
var dialog = new OpenInWorkspaceDialogViewModel("Synthetic", await host.HomeProjectsAsync(bed.SequenceId), _ => { }, copy: facts);
|
||||
Assert.SequenceEqual([Loc.L("Editor.OpenWorkspace.Size"), Loc.L("Editor.OpenWorkspace.Free")], dialog.CopyFacts.Select(f => f.Label));
|
||||
Assert.Equal(Formatting.Bytes(facts.Bytes), dialog.CopyFacts[0].Value);
|
||||
Assert.False(dialog.IsShortOfSpace);
|
||||
|
||||
var short_ = new OpenInWorkspaceDialogViewModel("Synthetic", [], _ => { }, copy: new WorkspaceCopyFacts(1_000_000, 1_000_000));
|
||||
Assert.True(short_.IsShortOfSpace);
|
||||
Assert.Equal(Loc.L("Errors.Workspace.NoRoom"), short_.CopyFacts[1].Reason);
|
||||
var unknown = new OpenInWorkspaceDialogViewModel("Synthetic", [], _ => { }, copy: new WorkspaceCopyFacts(1_000_000, null));
|
||||
Assert.Equal((false, Loc.L("Server.Sync.None")), (unknown.IsShortOfSpace, unknown.CopyFacts[1].Value));
|
||||
Assert.Empty(new OpenInWorkspaceDialogViewModel("Synthetic", [], _ => { }).CopyFacts);
|
||||
Assert.False(new WorkspaceCopyFacts(1_000, 1_000 + WorkspaceJobs.CopySpaceReserve).TooLittleSpace);
|
||||
Assert.True(new WorkspaceCopyFacts(1_000, 999 + WorkspaceJobs.CopySpaceReserve).TooLittleSpace);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AConflictOfFormatOffersOnlySaveBothAndSaysWhy()
|
||||
{
|
||||
var newer = new ConflictDialogViewModel("Main", "Main (STUDIO-PC)", ["Version 1 here, 2 in the library"], _ => Task.CompletedTask, _ => { },
|
||||
newerFormat: true);
|
||||
Assert.False(newer.CanMerge || newer.KeepMineCommand.CanExecute(null) || newer.TakeHomeCommand.CanExecute(null));
|
||||
Assert.True(newer.SaveBothCommand.CanExecute(null));
|
||||
Assert.SequenceEqual([Loc.L("Editor.Workspace.Conflict.NewerFormat")], newer.Differences);
|
||||
Assert.Equal(Loc.L("Editor.Workspace.Conflict.NewerMessage", "Main"), newer.Message);
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Workspace.NewerFormat"), newer.DifferencesToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Workspace.SaveBothNewer", "Main (STUDIO-PC)"), newer.SaveBothToolTip);
|
||||
|
||||
var merge = new ConflictDialogViewModel("Main", "Main (STUDIO-PC)", ["Hero frame 2 here, 3 in the library"], _ => Task.CompletedTask, _ => { });
|
||||
Assert.True(merge.CanMerge && merge.KeepMineCommand.CanExecute(null) && merge.TakeHomeCommand.CanExecute(null));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Workspace.SaveBoth", "Main (STUDIO-PC)"), merge.SaveBothToolTip);
|
||||
|
||||
// The format's numbers never reach the lines: one line names the cause.
|
||||
var lines = WorkspaceText.ConflictLines([new SettingsDifference(ProjectMerge.FormatPath, "1", "2"), new SettingsDifference("hero", "2", "3")], 10);
|
||||
Assert.SequenceEqual([Loc.L("Editor.Workspace.Conflict.NewerFormat")], lines);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AReadOnlyLibraryIsNamedAsSuchNotAsOffline()
|
||||
{
|
||||
var readOnly = new ArchiveOfflineException(@"E:\Library", ArchiveAvailability.ReadOnly);
|
||||
Assert.Equal(Loc.L("Errors.Workspace.ReadOnlyHome"), WorkspaceText.Failure(new HomeUnavailableException(readOnly.Message, readOnly)));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.ReadOnlyHome"), WorkspaceText.Failure(readOnly));
|
||||
var offline = new ArchiveOfflineException(@"E:\Library", ArchiveAvailability.Offline);
|
||||
Assert.Equal(Loc.L("Errors.Workspace.Offline"), WorkspaceText.Failure(new HomeUnavailableException(offline.Message, offline)));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.Offline"), WorkspaceText.Failure(new HomeUnavailableException("The project's home cannot be reached from this PC.")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PruningKeepsAVersionTheLibraryCannotGiveBack()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var settings = new AppSettings { WorkspaceKeptVersions = 100 };
|
||||
var host = bed.Host(settings);
|
||||
var mainId = await bed.CheckoutAsync(host);
|
||||
var (_, session) = await bed.OpenAsync(host, mainId);
|
||||
await using (session)
|
||||
{
|
||||
for (var i = 1; i <= 5; i++)
|
||||
{
|
||||
session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = i / 10.0 } });
|
||||
Assert.True(await session.FlushAsync());
|
||||
await host.SaveVersionAsync(mainId, $"Step {i}");
|
||||
}
|
||||
}
|
||||
var project = host.Store.Find(mainId)!;
|
||||
Assert.SequenceEqual([1, 2, 3, 4, 5, 6], project.Versions().Where(v => v.StoredAt is not null).Select(v => v.Number).Order());
|
||||
|
||||
// The library's file of version 2 is damaged: the workspace's copy is the only good one left, so it stays.
|
||||
var second = project.Versions().Single(v => v.Number == 2);
|
||||
var row = await bed.RowAsync();
|
||||
var library = (await bed.Db.Archives.GetAsync(row.ArchiveId))!.RootPath;
|
||||
var damaged = new ArchivePaths(library).Sequence(row.Folder).VersionPath(mainId, 2, second.Id);
|
||||
Assert.FileExists(damaged);
|
||||
await File.WriteAllTextAsync(damaged, "{ damaged", bed.Ct);
|
||||
|
||||
settings.WorkspaceKeptVersions = 2;
|
||||
Assert.Equal(3, await host.PruneAsync(mainId, host.HomeOfSequence(bed.SequenceId)));
|
||||
Assert.SequenceEqual([2, 5, 6], project.Versions().Where(v => v.StoredAt is not null).Select(v => v.Number).Order());
|
||||
}
|
||||
|
||||
/// <summary>Dialogs that pick <see cref="Folder"/> and answer every confirmation with <see cref="Answer"/>, recording what they were asked.</summary>
|
||||
private sealed class ScriptedDialogs : IAppDialogs
|
||||
{
|
||||
public string? Folder { get; set; }
|
||||
public bool Answer { get; set; }
|
||||
public List<ConfirmRequest> Asked { get; } = [];
|
||||
public string? PickFolder(string title, string? initialFolder = null) => Folder;
|
||||
public string? PickJsonFile(string title) => null;
|
||||
|
||||
public bool Confirm(ConfirmRequest request)
|
||||
{
|
||||
Asked.Add(request);
|
||||
return Answer;
|
||||
}
|
||||
|
||||
public bool SignIn(string server, string? username, Func<string, string, Task<string?>> signIn) => false;
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,80 @@ public abstract class WorkspaceConflictTests(TestContext context) : DatabaseTest
|
||||
ProjectSettings.FromJson(v.SettingsJson) is { Stack.Mode: StackSetting.StarTrails, Exposure.ExposureOffsetEv: 1.0 }), "the values taken over stay in a version");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TakingTheLibrarysValuesOverUnsavedChangesSendsNoVersion()
|
||||
{
|
||||
var (fx, _, two, id, shown) = await AskedAsync(await FixtureAsync());
|
||||
// Unsaved too: a setting only this side changed.
|
||||
await EditAsync(two, id, s => s with { Motion = s.Motion with { TargetShutterAngle = s.Motion.TargetShutterAngle.WithManual(90) } }, fx.Ct);
|
||||
var history = await fx.Home.HistoryAsync(id, null, 10, fx.Ct);
|
||||
|
||||
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.TakeServer, shown: shown, cancellationToken: fx.Ct);
|
||||
Assert.Null(settled.Status.Conflict);
|
||||
Assert.Empty(two.Unpushed(id), "no version of the working state is made, so none repeating the head is sent");
|
||||
Assert.Equal(WorkspaceState.Modified, settled.Status.State, "the change only this side made waits, unsaved as it was");
|
||||
var working = (await two.OpenAsync(id, fx.Ct)).Working;
|
||||
Assert.Equal((0.5, StackSetting.Median, 90.0), (working.Exposure.ExposureOffsetEv, working.Stack.Mode, working.Motion.TargetShutterAngle.Resolve(0)));
|
||||
Assert.Equal(1.0, Assert.NotNull(settled.Kept).Exposure.ExposureOffsetEv);
|
||||
Assert.Empty((await two.PushAsync(id, fx.Home, fx.Ct)).Pushed);
|
||||
Assert.Equal(history.Count, (await fx.Home.HistoryAsync(id, null, 10, fx.Ct)).Count, "the library's history holds no empty version");
|
||||
|
||||
// The value taken over stays in a version file set aside, outside the versions to send.
|
||||
var replaced = Path.Combine(two.Store.Find(id)!.VersionsDirectory, WorkspaceProject.ReplacedFolder);
|
||||
Assert.Contains(Directory.GetFiles(replaced).Select(ProjectSidecars.ReadVersion), v => ProjectSettings.FromJson(v.SettingsJson).Exposure.ExposureOffsetEv == 1.0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AConflictListsTheWorkingStatesValueAndOneAnswerSettlesIt()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (_, one) = fx.Workspace("one");
|
||||
var (_, two) = fx.Workspace("two");
|
||||
var id = (await fx.CheckoutAsync(one)).ProjectId;
|
||||
await fx.CheckoutAsync(two, id);
|
||||
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
|
||||
await one.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await one.PushAsync(id, fx.Home, fx.Ct);
|
||||
// This side saved 0.8 as a version, then went on to 1 without saving.
|
||||
await EditAsync(two, id, s => Offset(s, 0.8), fx.Ct);
|
||||
await two.CommitAsync(id, "warmer", cancellationToken: fx.Ct);
|
||||
await EditAsync(two, id, s => Offset(s, 1.0), fx.Ct);
|
||||
|
||||
var shown = Assert.NotNull((await two.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
|
||||
var difference = shown.Differences.Single();
|
||||
Assert.Equal(("exposure.exposureOffsetEv", 1.0, 0.5), (difference.Path, Number(difference.Mine), Number(difference.Theirs)),
|
||||
"this side's value is the one the editor shows");
|
||||
|
||||
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.TakeServer, shown: shown, cancellationToken: fx.Ct);
|
||||
Assert.Null(settled.Status.Conflict, "one answer settles what was shown");
|
||||
Assert.Equal(0.5, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv);
|
||||
Assert.Equal(1.0, Assert.NotNull(settled.Kept).Exposure.ExposureOffsetEv);
|
||||
Assert.Equal("warmer", two.Unpushed(id).Single().Note, "the saved version is replayed, nothing more");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task KeepMineKeepsTheWorkingStatesValueItListed()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (_, one) = fx.Workspace("one");
|
||||
var (_, two) = fx.Workspace("two");
|
||||
var id = (await fx.CheckoutAsync(one)).ProjectId;
|
||||
await fx.CheckoutAsync(two, id);
|
||||
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
|
||||
await one.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await one.PushAsync(id, fx.Home, fx.Ct);
|
||||
await EditAsync(two, id, s => Offset(s, 0.8), fx.Ct);
|
||||
await two.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await EditAsync(two, id, s => Offset(s, 1.0), fx.Ct);
|
||||
|
||||
var shown = Assert.NotNull((await two.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
|
||||
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.KeepMine, shown: shown, cancellationToken: fx.Ct);
|
||||
Assert.Null(settled.Status.Conflict);
|
||||
Assert.Equal(1.0, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv, "the value listed as this side's is kept");
|
||||
}
|
||||
|
||||
private static double? Number(string? json) => json is null ? null : double.Parse(json, System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
[Test]
|
||||
public async Task KeepMineIsAskedAgainWhenTheLibraryMovedOnASettingThisSideChanged()
|
||||
{
|
||||
|
||||
@@ -159,8 +159,7 @@ public abstract class WorkspaceRecoveryTests(TestContext context) : DatabaseTest
|
||||
Assert.Equal(WorkspaceState.InSync, (await one.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
||||
var head = Settings(await fx.Home.HeadAsync(id, fx.Ct));
|
||||
Assert.Equal((1.0, StackSetting.Mean), (head.Exposure.ExposureOffsetEv, head.Stack.Mode));
|
||||
// Taking the server's first saves the unsaved offset as a version, kept aside for its undo: replayed it holds the
|
||||
// server's values only, so it is not sent.
|
||||
// The unsaved offset taken over is kept aside, never sent: the home holds exactly these versions, in order.
|
||||
Assert.SequenceEqual(["first", "other", "second"], (await NotesAsync(fx, id)).Skip(1));
|
||||
Assert.Contains(Directory.GetFiles(Path.Combine(one.Store.Project(id).VersionsDirectory, WorkspaceProject.ReplacedFolder)),
|
||||
f => ProjectSidecars.ReadVersion(f) is { Note: null } saved && Settings(saved).Exposure.ExposureOffsetEv == 2.0);
|
||||
|
||||
Reference in new issue
Block a user