diff --git a/i18n/en/Archive.resx b/i18n/en/Archive.resx
index fa269f93..3c37491a 100644
--- a/i18n/en/Archive.resx
+++ b/i18n/en/Archive.resx
@@ -433,4 +433,14 @@
Health
View
Overview
+ {0}: originals copied: {1}, unchanged: {2}, without one: {3}long: job log line; {0} sequence; {1} originals copied; {2} already in the workspace; {3} frames whose original the home lacks
+ {0}: originals downloaded: {1}, unchanged: {2}, without one: {3}long: job log line; {0} sequence; {1} originals downloaded; {2} already in the workspace; {3} frames whose original the server did not give
+ {0}: frame {1} has no original at its home; its proxy stayslong: job log line; {0} sequence; {1} frame file name
+ {0}: originals the home no longer holds, kept in the trash: {1}long: job log line; {0} project name; {1} a count
+ {0}: renders sent: {1}, already there: {2}long: job log line; {0} project name; {1} renders sent; {2} the home held already
+ {0}: version {1} sent first, for its renderlong: job log line; {0} project name; {1} version number
+ Held while the connection is meteredlong: job log line
+ Workspace moved to {0}: projects: {1}, files: {2}long: job log line; {0} target folder; {1} and {2} counts
+ Move resumed from its journal: {0}long: job log line; {0} the journal file
+ Moved: {0}long: job log line; {0} project name
diff --git a/i18n/en/Editor.resx b/i18n/en/Editor.resx
index 724ff1df..350a4e3f 100644
--- a/i18n/en/Editor.resx
+++ b/i18n/en/Editor.resx
@@ -447,4 +447,36 @@
Undo
Update media
Updating media
+ Originals: {0}long; {0} a size, "1.2 GB"
+ Copy originals…
+ Proxies only…
+ Proxies only for {0}{0} project name
+ The originals copied to this PC are deleted once the library is checked to hold each one; renders then run where the originals are.long
+ The originals downloaded to this PC are deleted once the server is checked to hold each one; renders then run on the server.long
+ Originals: {0}long; {0} a count
+ Size: {0}long; {0} a size, "1.2 GB"
+ Kept in trash: {0}long; {0} a count
+ Delete originals
+ Copying originals
+ Originals copied
+ Originals removed
+ Originals not removed
+ Without original: {0}long; {0} a count of frames
+ Proxies
+ Originals
+ Open which project?
+ {0} has several projects in the workspace: choose the one to open.long; {0} sequence title
+ Render queued on this PC
+ On this PC
+ Sent home
+ {0} is in the library{0} render file name
+ {0} is on the server{0} render file name
+ Not sent
+ Render not sent
+ Send again
+ Sending render
+ Renderthe note of the version Version on render saves before a render
+ Version {0} saved for render{0} version number
+ Renders not sent
+ Last originals
diff --git a/i18n/en/Errors.resx b/i18n/en/Errors.resx
index fcc5c329..5eec3ce5 100644
--- a/i18n/en/Errors.resx
+++ b/i18n/en/Errors.resx
@@ -90,4 +90,28 @@
Some work is not on the server yet: send it first, or discard it.
This version is larger than the {0} MB a version can be, so the library cannot store it; your work stays in the workspace.{0} megabytes
This version is larger than the {0} MB a version can be, so the server cannot store it; your work stays in the workspace.{0} megabytes
+ This workspace job has no valid parameters.
+ The workspace holds no originals of this project: Copy originals… copies them from the library.
+ The workspace holds no originals of this project: Copy originals… downloads them from the server.
+ The original {0} did not match its SHA-256 after it was copied; it was not kept.
+ The library cannot be reached to check the originals against it; nothing was removed.
+ The server cannot be reached to check the originals against it; nothing was removed.
+ Save your changes as a version and wait for this project's jobs to end before changing its media.
+ Frames without an original in the workspace: {0}. Copy originals… copies them, then render again.
+ The version to render is not in the workspace: sync the project, then render again.
+ The project to render is no longer in the workspace.
+ {0} changed after it was rendered: it was not sent, and stays in the workspace.
+ The version this render was made from could not be sent first; the render waits in the workspace.
+ Renders not sent: {0} of {1}; the job log says why.
+ {0} is no longer in the workspace's exports; it cannot be sent.
+ Some renders made here are not in the library yet: send them first, or discard them.
+ Some renders made here are not on the server yet: send them first, or discard them.
+ The workspace's trash changed after it was listed; nothing was erased: look at it again.
+ The workspace folder is being moved; try again once the move ends.
+ {0} already holds a workspace or a project of this one: choose another folder.
+ {0} is the workspace folder or lies inside it: choose a folder elsewhere.
+ A workspace job is queued or running: move the folder once it ends.
+ The workspace changed after its plan was shown; nothing was moved: plan the move again.
+ {0} did not match its source after it was copied; the workspace stays where it was.
+ The target drive needs {0} GB more for the workspace.
diff --git a/i18n/en/Jobs.resx b/i18n/en/Jobs.resx
index f44956db..34f848d9 100644
--- a/i18n/en/Jobs.resx
+++ b/i18n/en/Jobs.resx
@@ -187,4 +187,23 @@
{0} → {1}invariant; {0} sequence title; {1} export preset
{0} ← {1}invariant; right-to-left languages: the arrow points from the sequence to the preset
this PC
+ Local render
+ Send render
+ Move workspace
+ Workspace clean-up
+ Workspace media
+ Workspace trash
+ Workspace: projects cleaned: {0}, freed: {1}, kept: {2}long: job log line; {0} a count; {1} a size; {2} a count of projects kept, each logged with why
+ Workspace: {0} used, nothing to cleanlong: job log line; {0} a size
+ Workspace: {0} kept: {1}long: job log line; {0} project name; {1} a reason, Jobs.Log.WorkspaceSkip.*
+ Workspace trash: items: {0}, size: {1}; nothing was deletedlong: job log line
+ Workspace not cleaned: its folder cannot be readlong: job log line
+ open in Edit
+ not in step with its home
+ its home is out of reach
+ a job is using it
+ renders not sent
+ it cannot be read
+ no media to remove
+ just copied
diff --git a/i18n/en/Server.resx b/i18n/en/Server.resx
index 403b4429..9fc8007c 100644
--- a/i18n/en/Server.resx
+++ b/i18n/en/Server.resx
@@ -256,4 +256,6 @@
{0} uses a certificate Chronos does not know yet. Compare the fingerprint with the one in the server's admin panel before you trust it.long
Trust this server?
v{0}
+ The project or version named with this render is not one of this sequence's.long
+ Pause metered transfers
diff --git a/i18n/en/Settings.resx b/i18n/en/Settings.resx
index dbc94927..62920c2b 100644
--- a/i18n/en/Settings.resx
+++ b/i18n/en/Settings.resx
@@ -212,4 +212,54 @@
Use folder
{0} version
{0} versions
+ Empty the workspace's trash?
+ What these entries kept, removed local copies and originals set aside among them, is erased for good; this cannot be undone.long
+ Entries: {0}long; {0} a count
+ Size: {0}long; {0} a size, "1.2 GB"
+ {0} · {1} · {2}invariant; {0} entry name; {1} its size; {2} when it was put in the trash
+ Type the number of entries, {0}, to confirmlong; {0} a count
+ Erase for good
+ Workspace trash emptied
+ Trash not emptied
+ {0} used{0} a size, "12.4 GB"
+ Measuring…
+ Move…
+ Size limit
+ No limit
+ Default media
+ Proxies
+ Originals
+ Version on render
+ Save before rendering
+ Clean after
+ Never
+ {0} day
+ {0} days
+ Open project
+ Last used
+ Main
+ Ask
+ Trash
+ {0} item, {1}{1} a size, "1.2 GB"
+ {0} items, {1}{1} a size, "1.2 GB"
+ Nothing in trash
+ Empty…
+ Choose where to move the workspacelong: folder picker title
+ Move the workspace?
+ The projects in {0} move to {1}, each file checked before its source is removed. Edit waits until the move ends.long; {0} the folder in use; {1} the folder chosen
+ Projects: {0}long; {0} a count
+ Files: {0}long; {0} a count
+ Size: {0}long; {0} a size, "1.2 GB"
+ Free at target: {0}long; {0} a size, "1.2 GB"
+ Same drive: folders renamedlong
+ Other drive: files copied and checkedlong
+ Not sent yet: {0}long; {0} a count of projects
+ Move
+ Move not possible
+ Moving the workspace
+ Workspace moved
+ Workspace not moved
+ Move not finished
+ A move of the workspace to {0} stopped before it ended; its projects are still in {1}.long; {0} the target folder; {1} the folder in use
+ Resume
diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx
index e7c68d6a..a0dfe097 100644
--- a/i18n/en/Tooltips.resx
+++ b/i18n/en/Tooltips.resx
@@ -937,4 +937,58 @@
Maximize
Minimize
Restore
+ What the copy of the originals writes into the workspace besides the proxies, as reckoned before it starts
+ Copy the proxies and the originals: renders then run on this PC, from the workspace; it takes the most space
+ Download the server's proxies and originals: renders then run on this PC, from the workspace; it takes the most space
+ The drive of the workspace folder lacks room for the originals and the 0.5 GB the copy keeps free: copy the proxies, or free some space
+ Copy this project's originals from the library into the workspace, to render on this PC
+ Download this project's originals from the server into the workspace, to render on this PC
+ Free this PC's space: delete the originals copied to the workspace once the library is checked to hold each one; the proxies stay
+ Free this PC's space: delete the originals downloaded to the workspace once the server is checked to hold each one; the proxies stay
+ Save your changes as a version and wait for this project's jobs to end first
+ Originals the library no longer holds as they are here: they go to the workspace's trash, not deleted
+ Originals the server no longer holds as they are here: they go to the workspace's trash, not deleted
+ Delete the originals listed from the workspace; the proxies and the project stay
+ Keep the originals in the workspace
+ The library had no original of these frames: they stay proxies here, and a local render waits until they are copied
+ The server had no original of these frames (or your account cannot read them): they stay proxies here
+ The workspace holds the proxies of this project: renders run where the originals are
+ The workspace holds the proxies and the originals of this project: renders run on this PC
+ Open this project of the sequence; Settings › Workspace › Open project says whether Edit asks
+ Rendered on this PC from the workspace's originals; the file is in the project's exports folder
+ Rendered on this PC, not in the library yet: it is sent with the next send; the file stays in the workspace
+ Rendered on this PC, not on the server yet: it is sent with the next send; the file stays in the workspace
+ Send the renders made here that the library does not have yet
+ Send the renders made here that the server does not have yet
+ Pause uploads and downloads with the server, workspace copies and renders sent among them, while Windows reports this connection as metered
+ Removes the media of workspace projects in step with their home: unopened past Clean after, or the oldest past Size limit
+ Lists what the workspace's trash holds; nothing is deleted
+ Renders made on this PC that the library does not have yet: Send first sends them, Discard keeps them in the workspace's trash
+ Renders made on this PC that the server does not have yet: Send first sends them, Discard keeps them in the workspace's trash
+ Originals the library no longer holds as they are here: they go to the workspace's trash, not deleted
+ Originals the server no longer holds as they are here: they go to the workspace's trash, not deleted
+ Erase every entry listed from the workspace's trash, for good; type their number above first
+ Keep the workspace's trash as it is
+ What the workspace folder takes on its drive, its trash included
+ The workspace's folder (a fast disk is best); Change uses another one, Move takes the projects along
+ Move the workspace folder with its projects to another folder, after a plan; each file is checked before its source goes
+ Past this size, the media of the projects used longest ago are removed once they are in step with their home; their versions stay
+ The workspace grows as needed; only Clean after removes media
+ What Open in workspace copies unless you choose otherwise there
+ Copy the proxies: light and fast to edit; renders run where the originals are
+ Copy the originals too, to render on this PC; it takes the most space
+ A render first saves your changes as a version (sent at once when Sync is on), so the render names the version it shows
+ Remove the media of projects not opened for this long, once they are in step with their home; opening one copies them again
+ Media stay until you remove them, or Size limit does
+ Which project Edit opens for a sequence with several in the workspace
+ The project you opened last for the sequence
+ The sequence's Main project, which holds its own settings
+ List the sequence's projects each time
+ What removed local copies and the clean-up kept aside; only Empty… erases it
+ Erase the workspace's trash for good, after a list of what it holds and a typed confirmation
+ The workspace's trash is empty
+ Projects with versions, changes or renders not at their home: they move with the rest, nothing is lost
+ Queue the move: the projects are moved or copied and checked, then Edit uses the new folder
+ Keep the workspace where it is
+ Queue the move again: it takes up from its journal, nothing is copied twice
diff --git a/i18n/it/Archive.it.resx b/i18n/it/Archive.it.resx
index c74b3721..4c9d6081 100644
--- a/i18n/it/Archive.it.resx
+++ b/i18n/it/Archive.it.resx
@@ -425,4 +425,14 @@
Stato
Vista
Panoramica
+ {0}: originali copiati: {1}, invariati: {2}, assenti: {3}
+ {0}: originali scaricati: {1}, invariati: {2}, assenti: {3}
+ {0}: il fotogramma {1} non ha l'originale all'origine; resta il suo proxy
+ {0}: originali che l'origine non ha più, tenuti nel cestino: {1}
+ {0}: render inviati: {1}, già presenti: {2}
+ {0}: versione {1} inviata prima, per il suo render
+ In attesa finché la connessione è a consumo
+ Spazio di lavoro spostato in {0}: progetti: {1}, file: {2}
+ Spostamento ripreso dal suo registro: {0}
+ Spostato: {0}
diff --git a/i18n/it/Editor.it.resx b/i18n/it/Editor.it.resx
index fe381624..e4d92e72 100644
--- a/i18n/it/Editor.it.resx
+++ b/i18n/it/Editor.it.resx
@@ -422,4 +422,36 @@
Annulla
Aggiorna media
Aggiornamento media
+ Originali: {0}
+ Copia originali…
+ Solo proxy…
+ Solo proxy per {0}
+ Gli originali copiati su questo PC vengono eliminati dopo aver verificato che la libreria li abbia tutti; i render avvengono poi dove sono gli originali.
+ Gli originali scaricati su questo PC vengono eliminati dopo aver verificato che il server li abbia tutti; i render avvengono poi sul server.
+ Originali: {0}
+ Dimensione: {0}
+ Tenuti nel cestino: {0}
+ Elimina originali
+ Copia degli originali
+ Originali copiati
+ Originali rimossi
+ Originali non rimossi
+ Senza originale: {0}
+ Proxy
+ Originali
+ Quale progetto aprire?
+ {0} ha più progetti nello spazio di lavoro: scegli quello da aprire.
+ Render in coda su questo PC
+ Su questo PC
+ Render inviato
+ {0} è nella libreria
+ {0} è sul server
+ Non inviato
+ Render non inviato
+ Invia di nuovo
+ Invio del render
+ Render
+ Versione {0} salvata per il render
+ Render non inviati
+ Ultimi originali
diff --git a/i18n/it/Errors.it.resx b/i18n/it/Errors.it.resx
index a6b9e20d..290ef057 100644
--- a/i18n/it/Errors.it.resx
+++ b/i18n/it/Errors.it.resx
@@ -90,4 +90,28 @@
Parte del lavoro non è ancora sul server: prima inviala oppure scartala.
Questa versione supera i {0} MB che una versione può occupare, quindi la libreria non può conservarla; il tuo lavoro resta nello spazio di lavoro.
Questa versione supera i {0} MB che una versione può occupare, quindi il server non può conservarla; il tuo lavoro resta nello spazio di lavoro.
+ Questa attività dello spazio di lavoro non ha parametri validi.
+ Lo spazio di lavoro non ha gli originali di questo progetto: Copia originali… li copia dalla libreria.
+ Lo spazio di lavoro non ha gli originali di questo progetto: Copia originali… li scarica dal server.
+ L'originale {0} non corrispondeva al suo SHA-256 dopo la copia; non è stato tenuto.
+ Non si raggiunge la libreria per verificare gli originali; non è stato rimosso nulla.
+ Non si raggiunge il server per verificare gli originali; non è stato rimosso nulla.
+ Salva le modifiche come versione e attendi la fine delle attività di questo progetto prima di cambiarne i media.
+ Fotogrammi senza originale nello spazio di lavoro: {0}. Copia originali… li copia, poi renderizza di nuovo.
+ La versione da renderizzare non è nello spazio di lavoro: sincronizza il progetto, poi renderizza di nuovo.
+ Il progetto da renderizzare non è più nello spazio di lavoro.
+ {0} è cambiato dopo il render: non è stato inviato e resta nello spazio di lavoro.
+ Non è stato possibile inviare prima la versione da cui è stato fatto questo render; il render attende nello spazio di lavoro.
+ Render non inviati: {0} di {1}; il log dell'attività dice perché.
+ {0} non è più negli export dello spazio di lavoro; non si può inviare.
+ Alcuni render fatti qui non sono ancora nella libreria: prima inviali oppure scartali.
+ Alcuni render fatti qui non sono ancora sul server: prima inviali oppure scartali.
+ Il cestino dello spazio di lavoro è cambiato dopo l'elenco; non è stato eliminato nulla: guardalo di nuovo.
+ La cartella dello spazio di lavoro è in spostamento; riprova a spostamento finito.
+ {0} contiene già uno spazio di lavoro o un progetto di questo: scegli un'altra cartella.
+ {0} è la cartella dello spazio di lavoro o si trova al suo interno: scegli una cartella altrove.
+ Un'attività dello spazio di lavoro è in coda o in corso: sposta la cartella quando finisce.
+ Lo spazio di lavoro è cambiato dopo che il piano è stato mostrato; non è stato spostato nulla: pianifica di nuovo.
+ {0} non corrispondeva alla sua origine dopo la copia; lo spazio di lavoro resta dov'era.
+ Al disco di destinazione servono altri {0} GB per lo spazio di lavoro.
diff --git a/i18n/it/Jobs.it.resx b/i18n/it/Jobs.it.resx
index 151e2e1b..7f65977e 100644
--- a/i18n/it/Jobs.it.resx
+++ b/i18n/it/Jobs.it.resx
@@ -185,4 +185,23 @@
Coda
Pianificate
questo PC
+ Rendering locale
+ Invio rendering
+ Sposta spazio di lavoro
+ Pulizia spazio di lavoro
+ Media spazio di lavoro
+ Cestino spazio di lavoro
+ Spazio di lavoro: progetti puliti: {0}, liberati: {1}, tenuti: {2}
+ Spazio di lavoro: {0} usati, niente da pulire
+ Spazio di lavoro: {0} tenuto: {1}
+ Cestino dello spazio di lavoro: elementi: {0}, dimensione: {1}; non è stato eliminato nulla
+ Spazio di lavoro non pulito: la sua cartella non è leggibile
+ aperto in Modifica
+ non allineato con l'origine
+ origine non raggiungibile
+ un'attività lo sta usando
+ render non inviati
+ non leggibile
+ nessun media da rimuovere
+ appena copiato
diff --git a/i18n/it/Server.it.resx b/i18n/it/Server.it.resx
index d4df3552..5cfccb71 100644
--- a/i18n/it/Server.it.resx
+++ b/i18n/it/Server.it.resx
@@ -253,4 +253,6 @@
{0} usa un certificato che Chronos non conosce ancora. Confronta l'impronta con quella del pannello di amministrazione del server prima di considerarlo attendibile.
Ti fidi di questo server?
v{0}
+ Il progetto o la versione indicati con questo render non sono di questa sequenza.
+ Pausa trasferimenti a consumo
diff --git a/i18n/it/Settings.it.resx b/i18n/it/Settings.it.resx
index 3a98ada2..ad86bc87 100644
--- a/i18n/it/Settings.it.resx
+++ b/i18n/it/Settings.it.resx
@@ -209,4 +209,54 @@
Usa cartella
{0} versione
{0} versioni
+ Svuotare il cestino?
+ Ciò che queste voci tenevano, comprese copie locali rimosse e originali messi da parte, viene eliminato per sempre; non si può annullare.
+ Voci: {0}
+ Dimensione: {0}
+ {0} · {1} · {2}
+ Scrivi il numero di voci, {0}, per confermare
+ Elimina per sempre
+ Cestino svuotato
+ Cestino non svuotato
+ {0} usati
+ Misura in corso…
+ Sposta…
+ Limite dimensione
+ Nessun limite
+ Media predefiniti
+ Proxy
+ Originali
+ Versione al render
+ Salva prima del render
+ Pulisci dopo
+ Mai
+ {0} giorno
+ {0} giorni
+ Apri progetto
+ Ultimo usato
+ Principale
+ Chiedi
+ Cestino
+ {0} elemento, {1}
+ {0} elementi, {1}
+ Cestino vuoto
+ Svuota…
+ Scegli dove spostare lo spazio di lavoro
+ Spostare lo spazio di lavoro?
+ I progetti in {0} vanno in {1}, ogni file verificato prima di rimuoverne l'origine. Modifica attende la fine dello spostamento.
+ Progetti: {0}
+ File: {0}
+ Dimensione: {0}
+ Libero alla meta: {0}
+ Stesso disco: cartelle rinominate
+ Altro disco: file copiati e verificati
+ Non ancora inviati: {0}
+ Sposta
+ Spostamento non possibile
+ Spostamento in corso
+ Spazio di lavoro spostato
+ Spazio di lavoro non spostato
+ Spostamento non finito
+ Uno spostamento dello spazio di lavoro in {0} si è fermato prima della fine; i progetti sono ancora in {1}.
+ Riprendi
diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx
index 9c5f333c..5382f4e7 100644
--- a/i18n/it/Tooltips.it.resx
+++ b/i18n/it/Tooltips.it.resx
@@ -935,4 +935,58 @@
Ingrandisci
Riduci a icona
Ripristina
+ Quanto scrive nello spazio di lavoro la copia degli originali oltre ai proxy, stimato prima che inizi
+ Copia i proxy e gli originali: i render avvengono poi su questo PC, dallo spazio di lavoro; occupa più spazio
+ Scarica i proxy e gli originali del server: i render avvengono poi su questo PC, dallo spazio di lavoro; occupa più spazio
+ Al disco della cartella dello spazio di lavoro manca spazio per gli originali e per gli 0,5 GB che la copia lascia liberi: copia i proxy o libera spazio
+ Copia gli originali di questo progetto dalla libreria nello spazio di lavoro, per renderizzare su questo PC
+ Scarica gli originali di questo progetto dal server nello spazio di lavoro, per renderizzare su questo PC
+ Libera spazio su questo PC: elimina gli originali copiati nello spazio di lavoro dopo aver verificato che la libreria li abbia tutti; i proxy restano
+ Libera spazio su questo PC: elimina gli originali scaricati nello spazio di lavoro dopo aver verificato che il server li abbia tutti; i proxy restano
+ Prima salva le modifiche come versione e attendi la fine delle attività di questo progetto
+ Originali che la libreria non ha più come sono qui: vanno nel cestino dello spazio di lavoro, non vengono eliminati
+ Originali che il server non ha più come sono qui: vanno nel cestino dello spazio di lavoro, non vengono eliminati
+ Elimina dallo spazio di lavoro gli originali elencati; i proxy e il progetto restano
+ Tieni gli originali nello spazio di lavoro
+ La libreria non aveva l'originale di questi fotogrammi: qui restano proxy, e un render locale attende finché non vengono copiati
+ Il server non aveva l'originale di questi fotogrammi (o il tuo account non può leggerli): qui restano proxy
+ Lo spazio di lavoro contiene i proxy di questo progetto: i render avvengono dove sono gli originali
+ Lo spazio di lavoro contiene i proxy e gli originali di questo progetto: i render avvengono su questo PC
+ Apri questo progetto della sequenza; Impostazioni › Spazio di lavoro › Apri progetto dice se Modifica lo chiede
+ Renderizzato su questo PC dagli originali dello spazio di lavoro; il file è nella cartella exports del progetto
+ Renderizzato su questo PC, non ancora nella libreria: viene inviato col prossimo invio; il file resta nello spazio di lavoro
+ Renderizzato su questo PC, non ancora sul server: viene inviato col prossimo invio; il file resta nello spazio di lavoro
+ Invia i render fatti qui che la libreria non ha ancora
+ Invia i render fatti qui che il server non ha ancora
+ Mette in pausa caricamenti e download col server, comprese copie dello spazio di lavoro e render inviati, mentre Windows segnala la connessione a consumo
+ Rimuove i media dei progetti allineati con la loro origine: non aperti oltre Pulisci dopo, o i più vecchi oltre Limite dimensione
+ Elenca cosa contiene il cestino dello spazio di lavoro; non elimina niente
+ Render fatti su questo PC che la libreria non ha ancora: Prima invia li invia, Scarta li tiene nel cestino dello spazio di lavoro
+ Render fatti su questo PC che il server non ha ancora: Prima invia li invia, Scarta li tiene nel cestino dello spazio di lavoro
+ Originali che la libreria non ha più come sono qui: vanno nel cestino dello spazio di lavoro, non vengono eliminati
+ Originali che il server non ha più come sono qui: vanno nel cestino dello spazio di lavoro, non vengono eliminati
+ Elimina per sempre ogni voce elencata dal cestino dello spazio di lavoro; prima scrivi il loro numero qui sopra
+ Lascia il cestino dello spazio di lavoro com'è
+ Quanto occupa la cartella dello spazio di lavoro sul suo disco, cestino compreso
+ La cartella dello spazio di lavoro (meglio un disco veloce); Cambia ne usa un'altra, Sposta porta con sé i progetti
+ Sposta la cartella dello spazio di lavoro con i suoi progetti in un'altra cartella, dopo un piano; ogni file è verificato prima di rimuovere l'origine
+ Oltre questa dimensione, i media dei progetti usati meno di recente vengono rimossi quando sono allineati con la loro origine; le versioni restano
+ Lo spazio di lavoro cresce quanto serve; solo Pulisci dopo rimuove i media
+ Cosa copia Apri nello spazio di lavoro, se lì non scegli altro
+ Copia i proxy: leggeri e veloci da modificare; i render avvengono dove sono gli originali
+ Copia anche gli originali, per renderizzare su questo PC; occupa più spazio
+ Un render salva prima le modifiche come versione (inviata subito con la sincronizzazione attiva), così il render indica la versione che mostra
+ Rimuove i media dei progetti non aperti da tanto, quando sono allineati con la loro origine; aprirne uno li ricopia
+ I media restano finché non li rimuovi tu o Limite dimensione
+ Quale progetto apre Modifica per una sequenza con più progetti nello spazio di lavoro
+ Il progetto che hai aperto per ultimo per la sequenza
+ Il progetto Principale della sequenza, che ne tiene le impostazioni
+ Elenca ogni volta i progetti della sequenza
+ Ciò che le copie locali rimosse e la pulizia hanno messo da parte; solo Svuota… lo elimina
+ Svuota per sempre il cestino dello spazio di lavoro, dopo un elenco di ciò che contiene e una conferma scritta
+ Il cestino dello spazio di lavoro è vuoto
+ Progetti con versioni, modifiche o render non ancora all'origine: si spostano col resto, non si perde nulla
+ Mette in coda lo spostamento: i progetti vengono spostati o copiati e verificati, poi Modifica usa la nuova cartella
+ Lascia lo spazio di lavoro dov'è
+ Rimette in coda lo spostamento: riparte dal suo registro, niente viene copiato due volte
diff --git a/src/Chronos.App/Infrastructure/AppServices.cs b/src/Chronos.App/Infrastructure/AppServices.cs
index 03c1c323..b60cbaea 100644
--- a/src/Chronos.App/Infrastructure/AppServices.cs
+++ b/src/Chronos.App/Infrastructure/AppServices.cs
@@ -178,15 +178,27 @@ public sealed class AppServices : IAsyncDisposable
typeof(AppServices).Assembly.GetCustomAttribute()?.InformationalVersion ?? "0.0.0";
/// The job handlers of this PC's engine — the single registration list; a kind without a handler stays
- /// queued (it is never claimed here). The workspace copy is the desktop's alone: it writes into this PC's workspace, from
- /// this PC's archive or, through the signed-in session, from a server.
+ /// queued (it is never claimed here). The workspace's jobs are the desktop's alone: they write into this PC's workspace
+ /// (a copy from this PC's archive or, through the signed-in session, from a server; a local render with this PC's
+ /// encoders; the sending of its renders home; the move of its folder, which Settings › Workspace then names).
public static IReadOnlyList CreateJobHandlers(AppServices services) =>
[
.. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? [],
.. services.Sync.Service?.CreateJobHandlers(services.Sync) ?? [],
- .. services.Database is { } db && services.Archives is { } archives ? WorkspaceJobs.CreateHandlers(db, archives, services.Sync) : [],
+ .. services.Database is { } db && services.Archives is { } archives
+ ? WorkspaceJobs.CreateHandlers(db, archives, services.Sync, WorkspaceOptions(services, archives))
+ : [],
];
+ ///
+ /// The workspace jobs' share of the desktop (phase 5c): its processing options for local renders, the metered hold of
+ /// Settings › Server over transfers with a server, and the workspace that follows a moved folder.
+ ///
+ private static WorkspaceJobOptions WorkspaceOptions(AppServices services, ArchiveService archives) =>
+ new(services.Processing?.Options ?? WorkspaceJobOptions.For(archives).Processing,
+ () => services.Settings.PauseUploadsOnMetered && MeteredNetwork.IsMetered(),
+ services.Workspace.MovedAsync);
+
///
/// Queues a scan of unless one is already waiting or running; the sequences it indexes get
/// a background deep analysis when Settings › Analysis asks for it.
diff --git a/src/Chronos.App/Infrastructure/AppSettings.cs b/src/Chronos.App/Infrastructure/AppSettings.cs
index 5e425a03..a2e2e6ac 100644
--- a/src/Chronos.App/Infrastructure/AppSettings.cs
+++ b/src/Chronos.App/Infrastructure/AppSettings.cs
@@ -7,6 +7,7 @@ using Chronos.Core.Diagnostics;
using Chronos.Core.Import;
using Chronos.Core.IO;
using Chronos.Core.Naming;
+using Chronos.Core.Project;
using Chronos.Data.Archiving;
using Chronos.Data.Repositories;
using Chronos.Ui.Theming;
@@ -39,6 +40,21 @@ public enum HardwarePreference
HardwareForPreviews,
}
+///
+/// Which project Edit opens for a sequence that has several in the workspace (Settings › Workspace › Open project, phase 5c).
+///
+public enum WorkspaceOpenPolicy
+{
+ /// The project opened last for the sequence (), else the one saved last.
+ LastUsed,
+
+ /// The sequence's Main project.
+ Main,
+
+ /// Ask each time, listing the sequence's projects.
+ Ask,
+}
+
/// A server certificate the user trusted on first use (BRIEF §12.7).
public sealed class TrustedCertificate
{
@@ -58,6 +74,8 @@ public sealed class AppSettings
public const int DefaultCacheLimitGb = 20;
public const int DefaultScanIntervalMinutes = 10;
public const int DefaultWorkspaceKeptVersions = 20;
+ public const int DefaultWorkspaceSizeLimitGb = 100;
+ public const int DefaultWorkspaceCleanAfterDays = 30;
/// 2⁻⁴ of white: the deep analysis' night threshold (a mean log2 luminance of −4).
public const double DefaultNightBrightnessPercent = 6.25;
@@ -169,6 +187,36 @@ public sealed class AppSettings
/// The workspace project opened last for each sequence (sequence id → project id); Edit opens it again.
public Dictionary WorkspaceRecent { get; set; } = [];
+ ///
+ /// Phase 5c: past this size (GB of 2³⁰ bytes) the workspace's clean-up removes the media of the projects used longest ago
+ /// that are in step with their home (never one open, with jobs, or with renders not sent); 0 = no limit.
+ ///
+ public int WorkspaceSizeLimitGb { get; set; } = DefaultWorkspaceSizeLimitGb;
+
+ ///
+ /// What "Open in workspace" copies unless chosen otherwise: or
+ /// (the proxies plus the originals, to render on this PC).
+ ///
+ public string WorkspaceDefaultMedia { get; set; } = BundleMedia.Proxies;
+
+ /// A render of a project with changes not saved as a version saves one first (and sends it when Sync automatically is on).
+ public bool WorkspaceVersionOnRender { get; set; } = true;
+
+ ///
+ /// The workspace's clean-up removes the media of a project not opened for this many days, once it is in step with its
+ /// home; 0 = never.
+ ///
+ public int WorkspaceCleanAfterDays { get; set; } = DefaultWorkspaceCleanAfterDays;
+
+ /// Which project Edit opens for a sequence with several in the workspace.
+ public WorkspaceOpenPolicy WorkspaceOpenProject { get; set; } = WorkspaceOpenPolicy.LastUsed;
+
+ ///
+ /// When each workspace project was last opened in Edit (project id → time), which the clean-up goes by (else the time
+ /// its working state was saved). This PC's, like .
+ ///
+ public Dictionary WorkspaceOpened { get; set; } = [];
+
// ---- Server ----
public string? ServerUrl { get; set; }
public string? ServerUsername { get; set; }
@@ -285,6 +333,64 @@ public sealed class AppSettings
/// A deep copy (JSON round trip), used for import and reset.
public AppSettings Clone() => Parse(ToJson()) ?? new AppSettings();
+
+ ///
+ /// Settings › Advanced › Reset: every default, but the values that are this PC's or this user's state rather than
+ /// preferences: the archive and the session, the window and its rail, the sequence edited last, the first-run flag, the
+ /// jobs cleared, and the workspace (its folder, moved only by its own operation, the projects opened last and when).
+ ///
+ public AppSettings ResetKeepingState() => new()
+ {
+ LastArchivePath = LastArchivePath,
+ ServerUrl = ServerUrl,
+ ServerUsername = ServerUsername,
+ ProtectedToken = ProtectedToken,
+ TrustedCertificates = TrustedCertificates,
+ RecentServers = RecentServers,
+ Window = Window,
+ RailCollapsed = RailCollapsed,
+ LastEditedSequence = LastEditedSequence,
+ FirstRunCompleted = FirstRunCompleted,
+ JobsClearedAt = JobsClearedAt,
+ WorkspaceFolder = WorkspaceFolder,
+ WorkspaceRecent = WorkspaceRecent,
+ WorkspaceOpened = WorkspaceOpened,
+ };
+
+ ///
+ /// Settings › Export: a copy without secrets and machine-bound values (the session, the window, the workspace's folder and
+ /// what it remembers of its projects: another PC's ids mean nothing there).
+ ///
+ public AppSettings ForExport()
+ {
+ var copy = Clone();
+ copy.ProtectedToken = null;
+ copy.Window = null;
+ copy.WorkspaceFolder = null;
+ copy.WorkspaceRecent = [];
+ copy.WorkspaceOpened = [];
+ return copy;
+ }
+
+ ///
+ /// Settings › Import: with this PC's own values taken from these settings: the session, the
+ /// window and its rail, the sequence edited last, the first-run flag, and the workspace (its folder, the projects opened
+ /// last and when). Changes and returns .
+ ///
+ public AppSettings KeepLocalIn(AppSettings imported)
+ {
+ ArgumentNullException.ThrowIfNull(imported);
+ imported.ProtectedToken = ProtectedToken;
+ imported.ServerUrl = ServerUrl;
+ imported.Window = Window;
+ imported.RailCollapsed = RailCollapsed;
+ imported.LastEditedSequence = LastEditedSequence;
+ imported.FirstRunCompleted = FirstRunCompleted;
+ imported.WorkspaceFolder = WorkspaceFolder;
+ imported.WorkspaceRecent = WorkspaceRecent;
+ imported.WorkspaceOpened = WorkspaceOpened;
+ return imported;
+ }
}
[JsonSourceGenerationOptions(WriteIndented = true, UseStringEnumConverter = true)]
diff --git a/src/Chronos.App/Jobs/JobNotices.cs b/src/Chronos.App/Jobs/JobNotices.cs
index 004a2d68..62a02834 100644
--- a/src/Chronos.App/Jobs/JobNotices.cs
+++ b/src/Chronos.App/Jobs/JobNotices.cs
@@ -40,7 +40,8 @@ public static class JobNotices
private static bool Announces(JobKind kind) =>
kind is JobKind.Render or JobKind.DeepAnalyse or JobKind.Verify or JobKind.Rebuild or JobKind.Maintenance or JobKind.UploadCommit
- or JobKind.Move or JobKind.Adopt or JobKind.EmptyTrash or JobKind.Convert;
+ or JobKind.Move or JobKind.Adopt or JobKind.EmptyTrash or JobKind.Convert or JobKind.WorkspaceRender or JobKind.WorkspaceSend
+ or JobKind.WorkspaceMove;
///
/// Work that keeps the index and its previews current: the next run repeats it, the Archive screen shows what is missing.
diff --git a/src/Chronos.App/Jobs/JobText.cs b/src/Chronos.App/Jobs/JobText.cs
index 95ddbe5b..d748456b 100644
--- a/src/Chronos.App/Jobs/JobText.cs
+++ b/src/Chronos.App/Jobs/JobText.cs
@@ -12,7 +12,7 @@ public static class JobText
/// True for jobs whose items are frames, so their speed reads in fps.
public static bool CountsFrames(JobKind kind) =>
- kind is JobKind.Render or JobKind.Proxies or JobKind.Thumbs or JobKind.DeepAnalyse;
+ kind is JobKind.Render or JobKind.Proxies or JobKind.Thumbs or JobKind.DeepAnalyse or JobKind.WorkspaceRender;
/// True for jobs whose progress counts bytes (hash verification, card import).
public static bool CountsBytes(JobKind kind) => kind is JobKind.Verify or JobKind.Import;
diff --git a/src/Chronos.App/Sections/SettingsViewModel.cs b/src/Chronos.App/Sections/SettingsViewModel.cs
index 83ccf08c..065a9dab 100644
--- a/src/Chronos.App/Sections/SettingsViewModel.cs
+++ b/src/Chronos.App/Sections/SettingsViewModel.cs
@@ -1207,7 +1207,8 @@ public sealed class SettingsViewModel : SectionViewModel
[
JobKind.Render, JobKind.Import, JobKind.Download, JobKind.UploadCommit, JobKind.Scan, JobKind.Rebuild, JobKind.Verify, JobKind.LightAnalyse,
JobKind.DeepAnalyse, JobKind.Thumbs, JobKind.Proxies, JobKind.Maintenance, JobKind.Duplicates, JobKind.Orphans, JobKind.Adopt, JobKind.Move,
- JobKind.Backup, JobKind.Cleanup, JobKind.EmptyTrash, JobKind.Convert, JobKind.WorkspaceCopy,
+ JobKind.Backup, JobKind.Cleanup, JobKind.EmptyTrash, JobKind.Convert, JobKind.WorkspaceCopy, JobKind.WorkspaceRender, JobKind.WorkspaceSend,
+ JobKind.WorkspaceMove,
];
/// Stores for , keeping only the levels that differ from the defaults.
@@ -1632,23 +1633,8 @@ public sealed class SettingsViewModel : SectionViewModel
IsDestructive = true,
});
if (!confirmed) return;
- var defaults = new AppSettings
- {
- LastArchivePath = _s.LastArchivePath,
- ServerUrl = _s.ServerUrl,
- ServerUsername = _s.ServerUsername,
- ProtectedToken = _s.ProtectedToken,
- TrustedCertificates = _s.TrustedCertificates,
- RecentServers = _s.RecentServers,
- Window = _s.Window,
- RailCollapsed = _s.RailCollapsed,
- LastEditedSequence = _s.LastEditedSequence,
- FirstRunCompleted = _s.FirstRunCompleted,
- JobsClearedAt = _s.JobsClearedAt,
- // The workspace holds this PC's work: its folder stays where it is (moving it is its own operation).
- WorkspaceFolder = _s.WorkspaceFolder,
- WorkspaceRecent = _s.WorkspaceRecent,
- };
+ // The workspace holds this PC's work: its folder stays where it is (moving it is its own operation).
+ var defaults = _s.ResetKeepingState();
// Start with Windows lives in the registry, not in the settings file: its default is off.
Startup.SetEnabled(false);
ApplyAll(defaults);
@@ -1690,12 +1676,8 @@ public sealed class SettingsViewModel : SectionViewModel
{
var folder = Shell.Services.Dialogs.PickFolder(Loc.L("Settings.Export.Title"));
if (folder is null) return;
- var copy = _s.Clone();
// Secrets and machine-bound values stay on this PC.
- copy.ProtectedToken = null;
- copy.Window = null;
- copy.WorkspaceFolder = null;
- copy.WorkspaceRecent = [];
+ var copy = _s.ForExport();
var path = Path.Combine(folder, $"Chronos settings {DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)}.json");
await Task.Run(() => AtomicFile.WriteAllText(path, copy.ToJson()));
Shell.Notify(Loc.L("Settings.Export.Done"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
@@ -1720,18 +1702,9 @@ public sealed class SettingsViewModel : SectionViewModel
Shell.Notify(Loc.L("Errors.Settings.Import"), isError: true);
return;
}
- // Everything but the session, the window and its rail, the sequence edited last (another PC's ids mean nothing here)
- // and the first-run flag.
- imported.ProtectedToken = _s.ProtectedToken;
- imported.ServerUrl = _s.ServerUrl;
- imported.Window = _s.Window;
- imported.RailCollapsed = _s.RailCollapsed;
- imported.LastEditedSequence = _s.LastEditedSequence;
- imported.FirstRunCompleted = _s.FirstRunCompleted;
- // The workspace is this PC's: its folder and the projects opened last stay.
- imported.WorkspaceFolder = _s.WorkspaceFolder;
- imported.WorkspaceRecent = _s.WorkspaceRecent;
- ApplyAll(imported);
+ // Everything but the session, the window and its rail, the sequence edited last (another PC's ids mean nothing here),
+ // the first-run flag and the workspace, which is this PC's (its folder, the projects opened last and when).
+ ApplyAll(_s.KeepLocalIn(imported));
// Settings of a PC never rewrite the shared archive.json: the imported templates and sizes are the defaults of new
// archives, and the rows show the own settings of the archive at the (possibly imported) archive folder.
_retarget = RetargetArchiveAsync();
diff --git a/src/Chronos.App/Workspace/WorkspaceFolderChange.cs b/src/Chronos.App/Workspace/WorkspaceFolderChange.cs
index 36d94f64..81c744a3 100644
--- a/src/Chronos.App/Workspace/WorkspaceFolderChange.cs
+++ b/src/Chronos.App/Workspace/WorkspaceFolderChange.cs
@@ -66,6 +66,31 @@ public static class WorkspaceFolderChange
}
}
+ ///
+ /// Settings › Workspace › Move… (phase 5c): the shell's flow over ,
+ /// with its folder picker, confirmation, editor and toasts. True when the move was queued.
+ ///
+ public static Task MoveAsync(ShellViewModel shell)
+ {
+ ArgumentNullException.ThrowIfNull(shell);
+ throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
+ }
+
+ ///
+ /// Picks the folder the workspace moves to through , shows its plan
+ /// () and asks for the user's word, lets close a
+ /// workspace project open in the editor (false keeps everything as it is), then queues the move
+ /// (). hears why it was refused. True when it was queued.
+ ///
+ public static Task MoveAsync(WorkspaceHost host, IAppDialogs dialogs, Func> closeProject, Action failed)
+ {
+ ArgumentNullException.ThrowIfNull(host);
+ ArgumentNullException.ThrowIfNull(dialogs);
+ ArgumentNullException.ThrowIfNull(closeProject);
+ ArgumentNullException.ThrowIfNull(failed);
+ throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
+ }
+
/// The plan as a confirmation: where Edit's projects come from now, and what stays where it is.
public static ConfirmRequest Request(WorkspaceFolderPlan plan)
{
diff --git a/src/Chronos.App/Workspace/WorkspaceHost.Cleanup.cs b/src/Chronos.App/Workspace/WorkspaceHost.Cleanup.cs
new file mode 100644
index 00000000..2a1e1f88
--- /dev/null
+++ b/src/Chronos.App/Workspace/WorkspaceHost.Cleanup.cs
@@ -0,0 +1,102 @@
+using System.IO;
+using Chronos.Core.Project;
+using Chronos.Data.Workspaces;
+
+namespace Chronos.App.Workspace;
+
+///
+/// What the workspace takes of its drive (Settings › Workspace, phase 5c): the projects' media (proxies and originals, which
+/// the clean-up and the size limit may remove), the whole folder, and its trash ().
+///
+/// The bytes of every project's media/ folder.
+/// The bytes of the whole workspace folder, its trash included.
+/// The bytes of the workspace's trash.
+/// The entries of the workspace's trash (one per copy removed or originals set aside).
+public sealed record WorkspaceUsage(long MediaBytes, long TotalBytes, long TrashBytes, int TrashItems)
+{
+ /// A workspace that holds nothing.
+ public static WorkspaceUsage None { get; } = new(0, 0, 0, 0);
+}
+
+/// One entry of the workspace's trash as Empty… lists it: its folder name, size, files and when it was put there.
+public sealed record WorkspaceTrashItem(string Name, long Bytes, int Files, DateTimeOffset Trashed);
+
+///
+/// The plan of Settings › Workspace › Trash › Empty… (phase 5c): every entry of the workspace's trash and their bytes, and a
+/// fingerprint over their names, sizes and times. Emptying erases exactly these entries, and only while the fingerprint
+/// still matches (the user types the number of entries to confirm); schedules and the size limit never empty the trash.
+///
+public sealed record WorkspaceTrashPlan(string Folder, IReadOnlyList Items, long Bytes, string Fingerprint)
+{
+ /// Nothing to erase: Empty… is disabled.
+ public bool IsEmpty => Items.Count == 0;
+}
+
+/// What emptying the workspace's trash erased.
+public sealed record WorkspaceTrashResult(int Items, long Bytes);
+
+///
+/// The workspace's clean-up side (phase 5c, P4): its usage, the plan and emptying of its trash, and what a local copy's removal
+/// keeps of renders not sent and originals the home lost. Stubs until the clean-up lands: usage and the trash read as empty,
+/// and a removal finds nothing more to keep.
+///
+public sealed partial class WorkspaceHost
+{
+ /// What the workspace takes of its drive (), measured off the UI thread.
+ public Task UsageAsync(CancellationToken cancellationToken = default)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ return Task.FromResult(WorkspaceUsage.None);
+ }
+
+ /// The plan of emptying the workspace's trash (); nothing is erased.
+ public Task PlanTrashAsync(CancellationToken cancellationToken = default)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ return Task.FromResult(new WorkspaceTrashPlan(Path.Combine(Root, TrashFolder), [], 0, string.Empty));
+ }
+
+ ///
+ /// Erases the entries of from the workspace's trash for good, after the user typed their number;
+ /// refused when the trash changed since the plan (Errors.Workspace.TrashChanged).
+ ///
+ /// The trash changed since the plan; nothing was erased.
+ public Task EmptyTrashAsync(WorkspaceTrashPlan plan, CancellationToken cancellationToken = default)
+ {
+ ArgumentNullException.ThrowIfNull(plan);
+ throw new NotImplementedException("Emptying the workspace's trash comes with phase 5c (P4).");
+ }
+
+ ///
+ /// What a local copy's removal plan counts besides its versions (,
+ /// ): renders of its ledger not sent, and originals the home no longer holds.
+ ///
+ private Task<(int UnsentRenders, int LastOriginals)> RemovalMediaAsync(WorkspaceProject project, CancellationToken cancellationToken)
+ {
+ ArgumentNullException.ThrowIfNull(project);
+ cancellationToken.ThrowIfCancellationRequested();
+ return Task.FromResult((0, 0));
+ }
+
+ /// A removal without Discard is refused while the project's ledger holds renders not sent (Send first sends them).
+ /// Renders wait to be sent.
+ private Task EnsureRendersSentAsync(WorkspaceProject project, BundleWorkspace workspace, CancellationToken cancellationToken)
+ {
+ ArgumentNullException.ThrowIfNull(project);
+ ArgumentNullException.ThrowIfNull(workspace);
+ cancellationToken.ThrowIfCancellationRequested();
+ return Task.CompletedTask;
+ }
+
+ ///
+ /// Before a removed copy's media are deleted, under the project's lease: the originals the home no longer holds with the
+ /// same SHA-256 moved into (the copy's trash entry), never deleted.
+ ///
+ private Task KeepLastOriginalsAsync(WorkspaceProject project, string aside, CancellationToken cancellationToken)
+ {
+ ArgumentNullException.ThrowIfNull(project);
+ ArgumentException.ThrowIfNullOrEmpty(aside);
+ cancellationToken.ThrowIfCancellationRequested();
+ return Task.CompletedTask;
+ }
+}
diff --git a/src/Chronos.App/Workspace/WorkspaceHost.Media.cs b/src/Chronos.App/Workspace/WorkspaceHost.Media.cs
new file mode 100644
index 00000000..d3ba872d
--- /dev/null
+++ b/src/Chronos.App/Workspace/WorkspaceHost.Media.cs
@@ -0,0 +1,25 @@
+using Chronos.Core.Localization;
+using Chronos.Data.Workspaces;
+
+namespace Chronos.App.Workspace;
+
+///
+/// The workspace's media (phase 5c, P1): what a copy writes (proxies, and the originals besides), copying the originals of a
+/// project, and going back to proxies only.
+///
+public sealed partial class WorkspaceHost
+{
+ /// The bytes the first copy of a sequence's media writes into the workspace, and the free bytes of the workspace's drive.
+ /// The index or the archive engine is not open.
+ public Task 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 () =>
+ {
+ var (bytes, free) = await WorkspaceJobs.CopyFactsAsync(db, archives, sequenceId, root, cancellationToken).ConfigureAwait(false);
+ return new WorkspaceCopyFacts(bytes, free);
+ }, cancellationToken);
+ }
+}
diff --git a/src/Chronos.App/Workspace/WorkspaceHost.Move.cs b/src/Chronos.App/Workspace/WorkspaceHost.Move.cs
new file mode 100644
index 00000000..9d70dfc6
--- /dev/null
+++ b/src/Chronos.App/Workspace/WorkspaceHost.Move.cs
@@ -0,0 +1,76 @@
+using Chronos.Core.Localization;
+using Chronos.Core.Model;
+
+namespace Chronos.App.Workspace;
+
+/// A project of the workspace as the plan of a move lists it: its size, and work not at its home yet (a warning, never a refusal).
+/// Versions or renders wait to be sent to its home.
+/// Changes not saved as a version.
+public sealed record WorkspaceMoveProject(Guid ProjectId, string Name, int Files, long Bytes, bool Unsent, bool Modified);
+
+///
+/// The plan of Settings › Workspace › Move… (phase 5c): the workspace folder moved with its projects to
+/// : the projects and their bytes, the free bytes at the target, whether both lie on one volume (folders
+/// renamed) or not (files copied and hash-verified), why it is refused (null when it can go), and a fingerprint of what
+/// the plan read, which the move job checks again.
+///
+/// The free bytes of the target's drive; null when they cannot be measured.
+///
+/// Why the move cannot go, one localized sentence: the target is the folder itself or inside it
+/// (Errors.Workspace.MoveSameFolder), already holds a workspace or a project of the same id
+/// (Errors.Workspace.MoveTargetNotEmpty), lacks the room (Errors.Workspace.DiskFull), or a workspace job is
+/// pending or running (Errors.Workspace.JobsRunning); null when it can go.
+///
+public sealed record WorkspaceMovePlan(string From, string To, IReadOnlyList Projects, int Files, long Bytes, long? Free, bool SameVolume,
+ string? Refusal, string Fingerprint)
+{
+ /// Nothing refuses the move.
+ public bool CanMove => Refusal is null;
+
+ /// Projects with work not at their home: the move keeps it, the plan says so.
+ public int Warnings => Projects.Count(p => p.Unsent || p.Modified);
+}
+
+///
+/// Moving the workspace folder with its projects (phase 5c, P6): the plan, the that
+/// carries it out, and the workspace that follows the folder once every file is verified there. While a move is queued or
+/// running the workspace is refused for syncs, saves and opens (). Stubs until the move lands.
+///
+public sealed partial class WorkspaceHost
+{
+ /// A move of the workspace folder is queued or running: syncs, saves and opens wait for it.
+ public bool IsMoving => false;
+
+ /// The plan of moving the workspace folder to (); nothing is written.
+ public Task PlanMoveAsync(string to, CancellationToken cancellationToken = default)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(to);
+ throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
+ }
+
+ /// Queues the of a plan the user confirmed.
+ /// The plan refuses the move.
+ public Task QueueMoveAsync(WorkspaceMovePlan plan, CancellationToken cancellationToken = default)
+ {
+ ArgumentNullException.ThrowIfNull(plan);
+ throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
+ }
+
+ ///
+ /// Told by the move job once every file of the workspace is verified at
+ /// (WorkspaceJobOptions.Moved): Settings › Workspace names the new folder and the workspace opens there.
+ ///
+ public Task MovedAsync(string from, string to)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(from);
+ ArgumentException.ThrowIfNullOrWhiteSpace(to);
+ throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
+ }
+
+ /// Refuses an operation that writes into the workspace while its folder is being moved.
+ /// A move is queued or running (Errors.Workspace.Moving).
+ private void EnsureNotMoving()
+ {
+ if (IsMoving) throw new WorkspaceException(Loc.L("Errors.Workspace.Moving"));
+ }
+}
diff --git a/src/Chronos.App/Workspace/WorkspaceHost.Render.cs b/src/Chronos.App/Workspace/WorkspaceHost.Render.cs
new file mode 100644
index 00000000..758047ae
--- /dev/null
+++ b/src/Chronos.App/Workspace/WorkspaceHost.Render.cs
@@ -0,0 +1,9 @@
+namespace Chronos.App.Workspace;
+
+///
+/// The workspace's local renders (phase 5c, P2): rendering a project from the originals it holds on this PC, and sending its
+/// renders home.
+///
+public sealed partial class WorkspaceHost
+{
+}
diff --git a/src/Chronos.App/Workspace/WorkspaceHost.cs b/src/Chronos.App/Workspace/WorkspaceHost.cs
index f45ffae6..61d5a5a5 100644
--- a/src/Chronos.App/Workspace/WorkspaceHost.cs
+++ b/src/Chronos.App/Workspace/WorkspaceHost.cs
@@ -70,8 +70,17 @@ public sealed record WorkspaceFolderPlan(string Current, string Folder, int Proj
}
/// 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.
-public sealed record WorkspaceCopyFacts(long Bytes, long? Free)
+/// What the copy of the proxies writes.
+/// What the copy of the originals writes besides (phase 5c); null when not known.
+public sealed record WorkspaceCopyFacts(long Bytes, long? Free, long? OriginalsBytes = null)
{
+ ///
+ /// The drive lacks room for the copy of (: the proxies and the
+ /// originals) and the reserve the copy keeps free.
+ ///
+ public bool TooLittleSpaceFor(string media) =>
+ Free is { } free && free < Bytes + (media == BundleMedia.Originals ? OriginalsBytes ?? 0 : 0) + WorkspaceJobs.CopySpaceReserve;
+
/// The drive lacks the copy and the reserve the copy keeps: it would stop saying so.
public bool TooLittleSpace => Free is { } free && free < Bytes + WorkspaceJobs.CopySpaceReserve;
}
@@ -113,8 +122,20 @@ public sealed record WorkspaceRemovalPlan(Guid ProjectId, string Name, int Files
///
public string? KnownName { get; init; }
+ ///
+ /// Local renders not at the home yet (phase 5c, the project's ledger): Send first sends them, Discard keeps them in the
+ /// workspace's trash with the rest of the work not sent.
+ ///
+ public int UnsentRenders { get; init; }
+
+ ///
+ /// Originals the workspace holds that the home no longer holds with the same SHA-256 (phase 5c): they go to the
+ /// workspace's trash, never deleted, when the copy is removed.
+ ///
+ public int LastOriginals { get; init; }
+
/// Everything the copy holds is at the home: it can go without discarding anything.
- public bool IsSafe => Unsent == 0 && !Modified && !Conflict && !Damaged;
+ public bool IsSafe => Unsent == 0 && UnsentRenders == 0 && !Modified && !Conflict && !Damaged;
}
///
@@ -129,7 +150,7 @@ public sealed record WorkspaceRemovalPlan(Guid ProjectId, string Name, int Files
/// Workspace › Kept versions only after the home returned each, a page of its history at a time. A capture (sample data, no
/// engine) has no workspace: Edit opens the library there.
///
-public sealed class WorkspaceHost
+public sealed partial class WorkspaceHost
{
/// Where discarded work of removed local copies is kept (the store lists only folders named by a project id).
public const string TrashFolder = ".trash";
@@ -358,20 +379,6 @@ public sealed class WorkspaceHost
Log.Info("workspace", $"The workspace folder is now {plan.Folder} ({plan.ProjectsLeft} project(s) stay in {plan.Current})");
}
- /// The bytes the first copy of a sequence's media writes into the workspace, and the free bytes of the workspace's drive.
- /// The index or the archive engine is not open.
- public Task 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 () =>
- {
- var (bytes, free) = await WorkspaceJobs.CopyFactsAsync(db, archives, sequenceId, root, cancellationToken).ConfigureAwait(false);
- return new WorkspaceCopyFacts(bytes, free);
- }, cancellationToken);
- }
-
/// The project of opened last here, else the one saved last; null when the workspace has none.
public async Task LastUsedAsync(Guid sequenceId, CancellationToken cancellationToken = default)
{
@@ -388,6 +395,16 @@ public sealed class WorkspaceHost
_savePreferences();
}
+ ///
+ /// Records that Edit opened at (now when null): the clean-up's Clean
+ /// after goes by it (phase 5c, ). Call it on the UI thread, which writes the settings.
+ ///
+ public void RecordOpened(Guid projectId, DateTimeOffset? at = null)
+ {
+ _settings.WorkspaceOpened[projectId] = at ?? DateTimeOffset.UtcNow;
+ _savePreferences();
+ }
+
/// The home's live projects of a sequence, Main first (made from the sequence's settings when it has none yet).
public Task> HomeProjectsAsync(Guid sequenceId, CancellationToken cancellationToken = default) =>
HomeProjectsAsync(ArchiveHome(sequenceId), cancellationToken);
@@ -426,6 +443,7 @@ public sealed class WorkspaceHost
var sequenceId = home.SequenceId;
var checkout = await Task.Run(async () =>
{
+ EnsureNotMoving();
// 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)) { FolderRefused = true };
@@ -461,6 +479,7 @@ public sealed class WorkspaceHost
///
public Task QueueCopyAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
{
+ EnsureNotMoving();
var bundle = Existing(projectId).ReadBundle();
return await QueueCopyCoreAsync(bundle.Workspace!.Home, projectId, bundle.Workspace.Media.Kind, bundle.Sequence.Title ?? string.Empty, cancellationToken)
.ConfigureAwait(false);
@@ -516,6 +535,7 @@ public sealed class WorkspaceHost
{
var version = await Task.Run(async () =>
{
+ EnsureNotMoving();
EnsureWritable(await Sync.StatusAsync(projectId, null, cancellationToken).ConfigureAwait(false));
return await Sync.CommitAsync(projectId, note, null, cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false);
@@ -538,6 +558,7 @@ public sealed class WorkspaceHost
/// The working state as a new local version without a note and without sending it; null when nothing changed.
public Task CommitAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
{
+ EnsureNotMoving();
EnsureWritable(await Sync.StatusAsync(projectId, null, cancellationToken).ConfigureAwait(false));
return await Sync.CommitAsync(projectId, null, null, cancellationToken).ConfigureAwait(false);
}, cancellationToken);
@@ -551,6 +572,7 @@ public sealed class WorkspaceHost
/// The home refused a version for good.
public Task SyncAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
{
+ EnsureNotMoving();
var home = HomeOfProject(projectId);
var pulled = await Sync.PullAsync(projectId, home, cancellationToken).ConfigureAwait(false);
// Deleted at the library: nothing to send, nothing to prune; the copy stays as it is.
@@ -570,6 +592,7 @@ public sealed class WorkspaceHost
public Task ResolveAsync(Guid projectId, ConflictChoice choice, IReadOnlySet? takeServer = null,
WorkspaceConflict? shown = null, CancellationToken cancellationToken = default) => Task.Run(async () =>
{
+ EnsureNotMoving();
var home = HomeOfProject(projectId);
WorkspaceSyncResult resolved;
if (choice == ConflictChoice.SaveBoth)
@@ -619,6 +642,7 @@ public sealed class WorkspaceHost
///
public Task RestoreAsync(Guid projectId, Guid versionId, CancellationToken cancellationToken = default) => Task.Run(async () =>
{
+ EnsureNotMoving();
var status = await Sync.StatusAsync(projectId, null, cancellationToken).ConfigureAwait(false);
if (status.ReadOnly) throw new WorkspaceException(Loc.L("Errors.Workspace.ReadOnly"));
if (status.MediaRemoved) throw new WorkspaceException(Loc.L("Errors.Workspace.MediaMissing"));
@@ -766,8 +790,9 @@ public sealed class WorkspaceHost
// A conflict recorded counts as work not at the home, also once the library no longer has the project (Gone asks none);
// one a settling replay took past its commit point is over, as the status reads it.
var conflict = status.Conflict is not null || project.OpenConflict() is not null;
+ var (unsentRenders, lastOriginals) = await RemovalMediaAsync(project, cancellationToken).ConfigureAwait(false);
return new WorkspaceRemovalPlan(projectId, name, files, bytes, status.Ahead + status.Damaged, status.Modified, conflict, status.Offline,
- status.State == WorkspaceState.Gone);
+ status.State == WorkspaceState.Gone) { UnsentRenders = unsentRenders, LastOriginals = lastOriginals };
}, cancellationToken);
///
@@ -802,6 +827,7 @@ public sealed class WorkspaceHost
// A version saved here that cannot be read may be one the home never had: only discarding keeps it aside.
if (status.Ahead > 0 || status.Damaged > 0 || (status.Modified && !status.ReadOnly) || status.Conflict is not null)
throw new WorkspaceException(Unsent(workspace.Home));
+ await EnsureRendersSentAsync(project, workspace, cancellationToken).ConfigureAwait(false);
await VerifyHomeAsync(projectId, workspace, cancellationToken).ConfigureAwait(false);
}
await RemoveFolderAsync(project, cancellationToken).ConfigureAwait(false);
@@ -950,6 +976,8 @@ public sealed class WorkspaceHost
}
throw;
}
+ // Originals the home no longer holds go aside with the rest; only what the home can make again is deleted.
+ await KeepLastOriginalsAsync(project, aside, cancellationToken).ConfigureAwait(false);
if (Directory.Exists(project.MediaDirectory)) Directory.Delete(project.MediaDirectory, recursive: true);
void Move(string from, string to)
@@ -1007,9 +1035,13 @@ public sealed class WorkspaceHost
private void Forget(Guid sequenceId, Guid projectId)
{
- if (!_settings.WorkspaceRecent.TryGetValue(sequenceId, out var known) || known != projectId) return;
- _settings.WorkspaceRecent.Remove(sequenceId);
- _savePreferences();
+ var changed = _settings.WorkspaceOpened.Remove(projectId);
+ if (_settings.WorkspaceRecent.TryGetValue(sequenceId, out var known) && known == projectId)
+ {
+ _settings.WorkspaceRecent.Remove(sequenceId);
+ changed = true;
+ }
+ if (changed) _savePreferences();
}
///
diff --git a/src/Chronos.Core/Model/Enums.cs b/src/Chronos.Core/Model/Enums.cs
index 54612451..b139f4b7 100644
--- a/src/Chronos.Core/Model/Enums.cs
+++ b/src/Chronos.Core/Model/Enums.cs
@@ -105,6 +105,24 @@ public enum JobKind
/// and resumable (owner review 2, R8); stored as 20.
///
WorkspaceCopy = 20,
+
+ ///
+ /// Renders a workspace project from the originals the workspace holds, on this PC, into the project's exports/
+ /// with a ledger entry per output (owner review 2, R8, phase 5c); stored as 21.
+ ///
+ WorkspaceRender = 21,
+
+ ///
+ /// Sends a workspace project's local renders home (this PC's archive or its server) with their project and version,
+ /// each hash-checked and idempotent by render id (owner review 2, R8, phase 5c); stored as 22.
+ ///
+ WorkspaceSend = 22,
+
+ ///
+ /// Moves the workspace folder with its projects to another folder, journaled and hash-verified across volumes, the
+ /// source kept until every file is verified (owner review 2, R8, phase 5c); stored as 23.
+ ///
+ WorkspaceMove = 23,
}
/// Why a photo left a sequence (its tombstone, owner review 2, R6); stored as a number.
diff --git a/src/Chronos.Data/Jobs/JobPriorityQueue.cs b/src/Chronos.Data/Jobs/JobPriorityQueue.cs
index fca96fd0..71b6d396 100644
--- a/src/Chronos.Data/Jobs/JobPriorityQueue.cs
+++ b/src/Chronos.Data/Jobs/JobPriorityQueue.cs
@@ -23,8 +23,9 @@ public sealed record JobPriorityQueue
{
///
/// The levels a kind has unless the user changed it: renders, imports and downloads first, and the copy of a project's
- /// media into the workspace, which Edit waits for (owner review 2, R8); the long passes that resume anywhere, and the
- /// housekeeping of the schedules (backups, clean-ups), last.
+ /// media into the workspace, which Edit waits for (owner review 2, R8), a workspace's local render and the move of the
+ /// workspace folder, which Edit is held for (phase 5c); a local render's sending home at the normal level; the long
+ /// passes that resume anywhere, and the housekeeping of the schedules (backups, clean-ups), last.
///
public static IReadOnlyDictionary DefaultLevels { get; } = new Dictionary
{
@@ -32,6 +33,9 @@ public sealed record JobPriorityQueue
[JobKind.Import] = JobKindPriority.High,
[JobKind.Download] = JobKindPriority.High,
[JobKind.WorkspaceCopy] = JobKindPriority.High,
+ [JobKind.WorkspaceRender] = JobKindPriority.High,
+ [JobKind.WorkspaceSend] = JobKindPriority.Normal,
+ [JobKind.WorkspaceMove] = JobKindPriority.High,
[JobKind.Verify] = JobKindPriority.Low,
[JobKind.Proxies] = JobKindPriority.Low,
[JobKind.Backup] = JobKindPriority.Low,
diff --git a/src/Chronos.Data/Sync/SyncTransfers.cs b/src/Chronos.Data/Sync/SyncTransfers.cs
index 6110d096..a8a816f6 100644
--- a/src/Chronos.Data/Sync/SyncTransfers.cs
+++ b/src/Chronos.Data/Sync/SyncTransfers.cs
@@ -558,14 +558,14 @@ internal sealed class SyncTransfers(SyncService sync)
}
}
- private static string? SafeFileName(string? name)
+ internal static string? SafeFileName(string? name)
{
var file = Path.GetFileName(name?.Trim());
return string.IsNullOrEmpty(file) || file.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || file is "." or ".." ? null : file;
}
/// "name.mp4", else "name (2).mp4", … — an existing export is never replaced.
- private static string Unique(string folder, string fileName)
+ internal static string Unique(string folder, string fileName)
{
var candidate = Path.Combine(folder, fileName);
var stem = Path.GetFileNameWithoutExtension(fileName);
@@ -693,7 +693,7 @@ internal sealed class SyncTransfers(SyncService sync)
/// manifest's SHA-256 (two attempts). A part as long as the file (a job stopped while hashing it) is only hashed again;
/// a part the server can no longer resume (416) starts over.
///
- private static async Task<(string Path, string Sha256)> FetchOriginalAsync(ISyncRemote remote, ManifestFrame frame, string staging,
+ internal static async Task<(string Path, string Sha256)> FetchOriginalAsync(ISyncRemote remote, ManifestFrame frame, string staging,
CancellationToken cancellationToken)
{
if (frame.Sha256.Length == 0) return await FetchUnhashedAsync(remote, frame, staging, cancellationToken).ConfigureAwait(false);
diff --git a/src/Chronos.Data/Workspaces/WorkspaceCopyJobHandler.cs b/src/Chronos.Data/Workspaces/WorkspaceCopyJobHandler.cs
index 1cf3f769..d788b35a 100644
--- a/src/Chronos.Data/Workspaces/WorkspaceCopyJobHandler.cs
+++ b/src/Chronos.Data/Workspaces/WorkspaceCopyJobHandler.cs
@@ -19,60 +19,6 @@ using SequenceManifest = Chronos.Protocol.SequenceManifest;
namespace Chronos.Data.Workspaces;
-/// Builds the jobs of the workspace (owner review 2, R8), and their handlers for the desktop's engine.
-public static class WorkspaceJobs
-{
- ///
- /// : the media of workspace project (checked out first,
- /// ) copied from its home, the sequence of this PC's archive.
- ///
- public static ArchiveJobRequest Copy(Sequence sequence, string workspaceRoot, Guid projectId, string media = BundleMedia.Proxies)
- {
- ArgumentNullException.ThrowIfNull(sequence);
- ArgumentException.ThrowIfNullOrWhiteSpace(workspaceRoot);
- return new ArchiveJobRequest(JobKind.WorkspaceCopy, [sequence.Id], sequence.DisplayTitle,
- JsonSerializer.Serialize(new WorkspaceCopyParameters(workspaceRoot, projectId, media), WorkspaceJson.Default.WorkspaceCopyParameters), JobPriority.User);
- }
-
- ///
- /// of a project whose home is a server (phase 5b): the media of workspace project
- /// (checked out first) downloaded from sequence of
- /// (), into the workspace alone. The job's target is the
- /// server's sequence, as for a sync download.
- ///
- public static ArchiveJobRequest CopyFromServer(Guid sequenceId, string title, string server, string workspaceRoot, Guid projectId, string media = BundleMedia.Proxies)
- {
- ArgumentException.ThrowIfNullOrWhiteSpace(server);
- ArgumentException.ThrowIfNullOrWhiteSpace(workspaceRoot);
- return new ArchiveJobRequest(JobKind.WorkspaceCopy, [sequenceId], title,
- JsonSerializer.Serialize(new WorkspaceCopyParameters(workspaceRoot, projectId, media, server), WorkspaceJson.Default.WorkspaceCopyParameters), JobPriority.User);
- }
-
- ///
- /// The handlers of the workspace's jobs for a desktop's engine (never a server's: the job writes into a folder its
- /// parameters name); copies from a server fail without a connection to it.
- ///
- public static IReadOnlyList CreateHandlers(ChronosDatabase db, ArchiveService archives) => CreateHandlers(db, archives, null);
-
- /// The connection a copy from a server's sequence downloads through (the desktop's signed-in session).
- public static IReadOnlyList CreateHandlers(ChronosDatabase db, ArchiveService archives, ISyncConnector? servers) =>
- [new WorkspaceCopyJobHandler(db, archives, servers)];
-
- ///
- /// 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 's
- /// drive (null when it cannot be measured): "Open in workspace" shows both. The copy keeps
- /// free besides.
- ///
- /// The index has no such sequence or archive.
- 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);
-
- /// Bytes the copy leaves free on the workspace's drive besides what it copies.
- public static long CopySpaceReserve => WorkspaceCopyJobHandler.SpaceReserve;
-}
-
///
/// for a sequence of this PC's archive (owner review 2, R8): its proxies into the
/// workspace project's media/proxies/<frame id>.jpg, the archive's own when current, else made here from the
diff --git a/src/Chronos.Data/Workspaces/WorkspaceJobs.cs b/src/Chronos.Data/Workspaces/WorkspaceJobs.cs
new file mode 100644
index 00000000..b3435793
--- /dev/null
+++ b/src/Chronos.Data/Workspaces/WorkspaceJobs.cs
@@ -0,0 +1,183 @@
+using System.Text.Json;
+using Chronos.Core.Model;
+using Chronos.Core.Project;
+using Chronos.Data.Archiving;
+using Chronos.Data.Archiving.Jobs;
+using Chronos.Data.Jobs;
+using Chronos.Data.Processing;
+using Chronos.Data.Sync;
+
+namespace Chronos.Data.Workspaces;
+
+///
+/// What the workspace's job handlers take from the desktop besides the index and the archive engine (phase 5c).
+///
+///
+/// Decoders, encoders and tuning of a local render (): the desktop's
+/// .
+///
+///
+/// True while transfers with a server are held (Settings › Server › Pause metered transfers on a metered connection): a
+/// or naming a server is not started then. Never
+/// holds a copy from or a send to this PC's archive.
+///
+///
+/// Told once a verified every file at its target (from, to): the desktop names the new
+/// folder in Settings › Workspace and refreshes the workspace; null where nothing follows the folder.
+///
+public sealed record WorkspaceJobOptions(ProcessingOptions Processing, Func HoldTransfers, Func? Moved = null)
+{
+ /// The options of an engine without a processing service of its own: the archive engine's decoders, nothing held, no move followed.
+ public static WorkspaceJobOptions For(ArchiveService archives)
+ {
+ ArgumentNullException.ThrowIfNull(archives);
+ return new WorkspaceJobOptions(new ProcessingOptions { Archive = new ArchiveServiceOptions { Decoder = archives.Decoder } }, () => false);
+ }
+}
+
+/// Builds the jobs of the workspace (owner review 2, R8), and their handlers for the desktop's engine.
+public static class WorkspaceJobs
+{
+ ///
+ /// : the media of workspace project (checked out first,
+ /// ) copied from its home, the sequence of this PC's archive.
+ ///
+ public static ArchiveJobRequest Copy(Sequence sequence, string workspaceRoot, Guid projectId, string media = BundleMedia.Proxies)
+ {
+ ArgumentNullException.ThrowIfNull(sequence);
+ ArgumentException.ThrowIfNullOrWhiteSpace(workspaceRoot);
+ return new ArchiveJobRequest(JobKind.WorkspaceCopy, [sequence.Id], sequence.DisplayTitle,
+ JsonSerializer.Serialize(new WorkspaceCopyParameters(workspaceRoot, projectId, media), WorkspaceJson.Default.WorkspaceCopyParameters), JobPriority.User);
+ }
+
+ ///
+ /// of a project whose home is a server (phase 5b): the media of workspace project
+ /// (checked out first) downloaded from sequence of
+ /// (), into the workspace alone. The job's target is the
+ /// server's sequence, as for a sync download.
+ ///
+ public static ArchiveJobRequest CopyFromServer(Guid sequenceId, string title, string server, string workspaceRoot, Guid projectId, string media = BundleMedia.Proxies)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(server);
+ ArgumentException.ThrowIfNullOrWhiteSpace(workspaceRoot);
+ return new ArchiveJobRequest(JobKind.WorkspaceCopy, [sequenceId], title,
+ JsonSerializer.Serialize(new WorkspaceCopyParameters(workspaceRoot, projectId, media, server), WorkspaceJson.Default.WorkspaceCopyParameters), JobPriority.User);
+ }
+
+ ///
+ /// (phase 5c): workspace project rendered on this PC from
+ /// the originals its media hold, into its exports/, as says (Protocol
+ /// RenderJobParameters with the portable settings: what writes for a render), each
+ /// output recorded with in the project's ledger and sent home after. The target is the
+ /// home's sequence (this PC's archive, or 's, ), so the
+ /// editor follows it as it follows a render of that sequence.
+ ///
+ public static ArchiveJobRequest Render(Guid sequenceId, string title, string workspaceRoot, Guid projectId, Guid? projectVersionId, string renderJson,
+ string? server = null)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(workspaceRoot);
+ ArgumentException.ThrowIfNullOrWhiteSpace(renderJson);
+ return new ArchiveJobRequest(JobKind.WorkspaceRender, [sequenceId], title,
+ JsonSerializer.Serialize(new WorkspaceRenderParameters(workspaceRoot, projectId, projectVersionId, renderJson, server),
+ WorkspaceJson.Default.WorkspaceRenderParameters), JobPriority.User);
+ }
+
+ ///
+ /// (phase 5c): the local renders of workspace project
+ /// (every unsent one of its ledger when empty) sent to its home, the sequence of this PC's
+ /// archive or of (), with their project and version.
+ ///
+ public static ArchiveJobRequest Send(Guid sequenceId, string title, string workspaceRoot, Guid projectId, IReadOnlyList renderIds, string? server = null,
+ JobPriority priority = JobPriority.User)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(workspaceRoot);
+ ArgumentNullException.ThrowIfNull(renderIds);
+ return new ArchiveJobRequest(JobKind.WorkspaceSend, [sequenceId], title,
+ JsonSerializer.Serialize(new WorkspaceSendParameters(workspaceRoot, projectId, [.. renderIds], server), WorkspaceJson.Default.WorkspaceSendParameters),
+ priority);
+ }
+
+ ///
+ /// (phase 5c): the workspace folder moved with its projects to
+ /// , as the plan of fingerprint the user confirmed showed it. The
+ /// job has no target; its label is the folder it moves to.
+ ///
+ public static ArchiveJobRequest Move(string from, string to, string planFingerprint)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(from);
+ ArgumentException.ThrowIfNullOrWhiteSpace(to);
+ ArgumentException.ThrowIfNullOrWhiteSpace(planFingerprint);
+ return new ArchiveJobRequest(JobKind.WorkspaceMove, [], to,
+ JsonSerializer.Serialize(new WorkspaceMoveParameters(from, to, planFingerprint), WorkspaceJson.Default.WorkspaceMoveParameters), JobPriority.User);
+ }
+
+ /// The parameters of a job; null when it has none that read.
+ public static WorkspaceRenderParameters? RenderParameters(Job job) => Read(job, JobKind.WorkspaceRender, WorkspaceJson.Default.WorkspaceRenderParameters);
+
+ /// The parameters of a job; null when it has none that read.
+ public static WorkspaceSendParameters? SendParameters(Job job) => Read(job, JobKind.WorkspaceSend, WorkspaceJson.Default.WorkspaceSendParameters);
+
+ /// The parameters of a job; null when it has none that read.
+ public static WorkspaceMoveParameters? MoveParameters(Job job) => Read(job, JobKind.WorkspaceMove, WorkspaceJson.Default.WorkspaceMoveParameters);
+
+ /// The parameters of a job; null when it has none that read.
+ public static WorkspaceCopyParameters? CopyParameters(Job job) => Read(job, JobKind.WorkspaceCopy, WorkspaceJson.Default.WorkspaceCopyParameters);
+
+ ///
+ /// The handlers of the workspace's jobs for a desktop's engine (never a server's: the job writes into a folder its
+ /// parameters name); copies from a server fail without a connection to it.
+ ///
+ public static IReadOnlyList CreateHandlers(ChronosDatabase db, ArchiveService archives) => CreateHandlers(db, archives, null);
+
+ /// The connection a copy from a server's sequence downloads through (the desktop's signed-in session).
+ public static IReadOnlyList CreateHandlers(ChronosDatabase db, ArchiveService archives, ISyncConnector? servers) =>
+ CreateHandlers(db, archives, servers, WorkspaceJobOptions.For(archives));
+
+ ///
+ /// The handlers of every workspace job (phase 5c): the copy of a project's media, its local render, the sending of its
+ /// renders home and the move of the workspace folder.
+ ///
+ /// The connection a copy from, or a send to, a server's sequence goes through (the desktop's signed-in session).
+ /// The desktop's processing options, its hold on transfers and what follows a moved folder.
+ public static IReadOnlyList CreateHandlers(ChronosDatabase db, ArchiveService archives, ISyncConnector? servers, WorkspaceJobOptions options)
+ {
+ ArgumentNullException.ThrowIfNull(db);
+ ArgumentNullException.ThrowIfNull(archives);
+ ArgumentNullException.ThrowIfNull(options);
+ return
+ [
+ new WorkspaceCopyJobHandler(db, archives, servers),
+ new WorkspaceRenderJobHandler(db, archives, options),
+ new WorkspaceSendJobHandler(db, archives, servers, options),
+ new WorkspaceMoveJobHandler(db, options),
+ ];
+ }
+
+ ///
+ /// 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 's
+ /// drive (null when it cannot be measured): "Open in workspace" shows both. The copy keeps
+ /// free besides.
+ ///
+ /// The index has no such sequence or archive.
+ 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);
+
+ /// Bytes the copy leaves free on the workspace's drive besides what it copies.
+ public static long CopySpaceReserve => WorkspaceCopyJobHandler.SpaceReserve;
+
+ private static T? Read(Job job, JobKind kind, System.Text.Json.Serialization.Metadata.JsonTypeInfo info) where T : class
+ {
+ ArgumentNullException.ThrowIfNull(job);
+ if (job.Kind != kind || job.ParametersJson is not { Length: > 0 } json) return null;
+ try
+ {
+ return JsonSerializer.Deserialize(json, info);
+ }
+ catch (JsonException)
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/Chronos.Data/Workspaces/WorkspaceMedia.cs b/src/Chronos.Data/Workspaces/WorkspaceMedia.cs
index e87d2b49..59079d8e 100644
--- a/src/Chronos.Data/Workspaces/WorkspaceMedia.cs
+++ b/src/Chronos.Data/Workspaces/WorkspaceMedia.cs
@@ -17,6 +17,13 @@ namespace Chronos.Data.Workspaces;
/// What the file is when a server sent it (phase 5b): proxy, or thumb, a thumbnail standing in while the server
/// had no proxy of the frame, which a later copy replaces once it has one; null for a proxy (copies from this PC's archive).
///
+///
+/// The frame's original the workspace holds, relative to the media folder (:
+/// "originals/<frame id>-<sha8><ext>", phase 5c), in media of kind ; null
+/// when it holds none (proxies only, or the home had no original of the frame: the proxy stands in for editing).
+///
+/// The original's SHA-256 as copied and checked (lower case); null with .
+/// The original's size as copied; 0 with no original.
public sealed record WorkspaceFrame(
Guid Id,
int Index,
@@ -46,7 +53,10 @@ public sealed record WorkspaceFrame(
string? File,
string? FileSha256,
long FileBytes,
- string? FileKind = null)
+ string? FileKind = null,
+ string? Original = null,
+ string? OriginalSha256 = null,
+ long OriginalBytes = 0)
{
/// The record of a home's frame, with the file the workspace holds for it (: what a server sent).
public static WorkspaceFrame Of(Frame frame, string? file, string? fileSha256, long fileBytes, string? fileKind = null)
@@ -62,6 +72,24 @@ public sealed record WorkspaceFrame(
[JsonIgnore]
public bool IsStandIn => FileKind == Sync.ProxyCache.Thumb;
+ /// The workspace holds the frame's original (media of kind ).
+ [JsonIgnore]
+ public bool HasOriginal => Original is not null;
+
+ ///
+ /// The frame as a render from the workspace's originals reads it (phase 5c): its file is , and
+ /// it is flagged missing while the workspace holds no original for it (a render refuses such media first).
+ ///
+ public Frame ToOriginalFrame(Guid sequenceId)
+ {
+ var frame = ToFrame(sequenceId);
+ return frame with
+ {
+ RelativePath = Original ?? FileName,
+ Flags = Original is null ? Flags | FrameFlags.Missing : Flags,
+ };
+ }
+
/// The frame as the processing engine reads it; flagged missing while the workspace holds no file for it.
public Frame ToFrame(Guid sequenceId) => new()
{
@@ -97,8 +125,10 @@ public sealed record WorkspaceFrame(
///
/// What a workspace project holds of its sequence's photos (media/media.json, owner review 2, R8): the kind
-/// (; originals in phase 5c), the sequence and its frames version at the home when they
-/// were copied, and every frame in index order. Written last by a copy, so a copy cut short leaves the previous index.
+/// (, or from phase 5c : the proxies plus each frame's
+/// original, ), the sequence and its frames version at the home when they were
+/// copied, and every frame in index order. Written last by a copy, so a copy cut short leaves the previous index. An index
+/// of phase 5b has no original fields: it reads as proxies only.
///
/// The encodings of the sequence's photos a conversion joined at the home (R7, its tombstones of reason
/// "replaced") when the media were copied: a version parked on a photo before its file was converted still finds its frame.
@@ -115,6 +145,13 @@ public sealed record WorkspaceMedia(string Format, int FormatVersion, string Kin
/// The frames held, as the processing engine reads them.
public IReadOnlyList ToFrames() => [.. Frames.Select(f => f.ToFrame(SequenceId))];
+ /// The frames over the originals the workspace holds (), as a local render reads them.
+ public IReadOnlyList ToOriginalFrames() => [.. Frames.Select(f => f.ToOriginalFrame(SequenceId))];
+
+ /// Media of kind : the proxies plus the originals the frames name.
+ [JsonIgnore]
+ public bool HoldsOriginals => Kind == BundleMedia.Originals;
+
///
/// These media with their photos named as names them now (owner review 2, R8): a frame copied
/// before the home hashed its photo (a folder adopted, verified since) takes the SHA-256 the home's frame of that id has
diff --git a/src/Chronos.Data/Workspaces/WorkspaceMoveJobHandler.cs b/src/Chronos.Data/Workspaces/WorkspaceMoveJobHandler.cs
new file mode 100644
index 00000000..6df7803b
--- /dev/null
+++ b/src/Chronos.Data/Workspaces/WorkspaceMoveJobHandler.cs
@@ -0,0 +1,23 @@
+using Chronos.Core.Model;
+using Chronos.Data.Jobs;
+
+namespace Chronos.Data.Workspaces;
+
+///
+/// (phase 5c, ): the workspace folder moved with its
+/// projects, after the plan the user confirmed (its fingerprint checked again): journaled in <from>/.move.json,
+/// moved per project on one volume, copied and hash-verified on both sides across volumes, a project's source deleted only
+/// once every file of it is verified, resumable from the journal; at the end is told.
+/// On failure the source stays the workspace and unverified partial copies are removed.
+///
+internal sealed class WorkspaceMoveJobHandler(ChronosDatabase db, WorkspaceJobOptions options) : IJobHandler
+{
+ public JobKind Kind => JobKind.WorkspaceMove;
+
+ public Task RunAsync(JobContext context)
+ {
+ ArgumentNullException.ThrowIfNull(context);
+ _ = (db, options);
+ throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
+ }
+}
diff --git a/src/Chronos.Data/Workspaces/WorkspaceRenderJobHandler.cs b/src/Chronos.Data/Workspaces/WorkspaceRenderJobHandler.cs
new file mode 100644
index 00000000..f37c4e52
--- /dev/null
+++ b/src/Chronos.Data/Workspaces/WorkspaceRenderJobHandler.cs
@@ -0,0 +1,24 @@
+using Chronos.Core.Model;
+using Chronos.Data.Archiving;
+using Chronos.Data.Jobs;
+
+namespace Chronos.Data.Workspaces;
+
+///
+/// (phase 5c, ): a workspace project rendered on this
+/// PC from the originals its media hold, as renders an archive's sequence,
+/// into the project's exports/ (each output written as .part, then renamed), each output hashed and recorded in
+/// the project's ledger (, its id RenderJobHandler.RenderId(jobId, index)), then a
+/// queued with the new ids. Media without an original for every placed frame are refused.
+///
+internal sealed class WorkspaceRenderJobHandler(ChronosDatabase db, ArchiveService archives, WorkspaceJobOptions options) : IJobHandler
+{
+ public JobKind Kind => JobKind.WorkspaceRender;
+
+ public Task RunAsync(JobContext context)
+ {
+ ArgumentNullException.ThrowIfNull(context);
+ _ = (db, archives, options);
+ throw new NotImplementedException("Local renders of a workspace project come with phase 5c (P2).");
+ }
+}
diff --git a/src/Chronos.Data/Workspaces/WorkspaceRenders.cs b/src/Chronos.Data/Workspaces/WorkspaceRenders.cs
new file mode 100644
index 00000000..88d0dc5e
--- /dev/null
+++ b/src/Chronos.Data/Workspaces/WorkspaceRenders.cs
@@ -0,0 +1,136 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using Chronos.Core.IO;
+using Chronos.Core.Model;
+
+namespace Chronos.Data.Workspaces;
+
+///
+/// One local render of a workspace project (phase 5c), as its ledger () records it: the output
+/// a wrote into the project's exports/, its SHA-256 and size as written, what it
+/// is (preset, codec, size, rate, length), the project and version it was rendered from, and whether it went home
+/// (). The file stays in exports/ after it is sent, until a clean-up removes it.
+///
+///
+/// The render's id, the same at the home once sent (RenderJobHandler.RenderId(jobId, index)): a send repeated after a
+/// cut finds the home holding it already, and nothing is filed twice.
+///
+/// The job that wrote it.
+/// The output, relative to the project's exports/ folder (forward slashes; ).
+/// The output's SHA-256 (lower case) as it was written: a send hashes the file again and refuses another.
+/// The output's size in bytes.
+/// The project version rendered; null for a working state no version names.
+/// The content hash of the portable settings rendered (ProjectContent); null when not known.
+/// When the output was finished.
+/// , or (a later Chronos may write others: read as pending).
+/// When the home took it; null until then.
+/// Why the last send failed (one localized sentence); null otherwise.
+public sealed record WorkspaceRenderEntry(
+ Guid RenderId,
+ Guid JobId,
+ string File,
+ string Sha256,
+ long Size,
+ string PresetName,
+ string? Codec,
+ int Width,
+ int Height,
+ double Fps,
+ double DurationSeconds,
+ Guid ProjectId,
+ Guid? ProjectVersionId,
+ string? SettingsHash,
+ DateTimeOffset Rendered,
+ string State = WorkspaceRenderEntry.Pending,
+ DateTimeOffset? Sent = null,
+ string? Error = null)
+{
+ /// Written, not at the home yet.
+ public const string Pending = "pending";
+
+ /// The home holds it (a render row of the home's sequence with this id).
+ public const string SentState = "sent";
+
+ /// The last send failed ( says why); sent again by the next send.
+ public const string Failed = "failed";
+
+ /// The home holds this render.
+ [JsonIgnore]
+ public bool IsSent => State == SentState;
+
+ /// Not at the home yet: pending, failed, or a state this Chronos does not know. A clean-up never removes its file.
+ [JsonIgnore]
+ public bool IsUnsent => !IsSent;
+
+ /// This entry as taken by the home at .
+ public WorkspaceRenderEntry AsSent(DateTimeOffset at) => this with { State = SentState, Sent = at, Error = null };
+
+ /// This entry after a send that failed for ; it stays to be sent again.
+ public WorkspaceRenderEntry AsFailed(string error) => this with { State = Failed, Error = error };
+}
+
+///
+/// The ledger of a workspace project's local renders (exports/renders.json, phase 5c): every output a
+/// finished, oldest first, one entry per render id. Read whole and written whole and
+/// atomically (temporary file, flush, rename), always under the project's lease; a missing ledger is an empty one.
+///
+public sealed record WorkspaceRenders(string Format, int FormatVersion, IReadOnlyList Entries)
+{
+ public const string FormatName = "chronos-workspace-renders";
+ public const int CurrentFormatVersion = 1;
+
+ /// A ledger without entries.
+ public static WorkspaceRenders Empty { get; } = new(FormatName, CurrentFormatVersion, []);
+
+ /// The entries not at the home yet (), oldest first.
+ [JsonIgnore]
+ public IReadOnlyList Unsent => [.. Entries.Where(e => e.IsUnsent)];
+
+ /// The entry of ; null when the ledger has none.
+ public WorkspaceRenderEntry? Find(Guid renderId) => Entries.FirstOrDefault(e => e.RenderId == renderId);
+
+ /// This ledger with in place of the entry of its render id, or appended when it has none.
+ public WorkspaceRenders With(WorkspaceRenderEntry entry)
+ {
+ ArgumentNullException.ThrowIfNull(entry);
+ var entries = Entries.ToList();
+ var at = entries.FindIndex(e => e.RenderId == entry.RenderId);
+ if (at >= 0) entries[at] = entry;
+ else entries.Add(entry);
+ return this with { Entries = entries };
+ }
+
+ /// This ledger without the entry of (a sent file a clean-up removed, a discarded render).
+ public WorkspaceRenders Without(Guid renderId) => Entries.Any(e => e.RenderId == renderId) ? this with { Entries = [.. Entries.Where(e => e.RenderId != renderId)] } : this;
+
+ /// The ledger at ; when there is none.
+ /// The file is no ledger, is damaged, or a newer Chronos wrote it.
+ /// The file cannot be read.
+ public static WorkspaceRenders Read(string path)
+ {
+ ArgumentException.ThrowIfNullOrEmpty(path);
+ if (!System.IO.File.Exists(path)) return Empty;
+ WorkspaceRenders? renders;
+ try
+ {
+ renders = JsonSerializer.Deserialize(AtomicFile.ReadAllText(path), WorkspaceJson.Default.WorkspaceRenders);
+ }
+ catch (JsonException ex)
+ {
+ throw new InvalidDataException($"{path} cannot be read.", ex);
+ }
+ if (renders is null || renders.Format != FormatName || renders.Entries is null) throw new InvalidDataException($"{path} is not a renders ledger.");
+ if (renders.FormatVersion > CurrentFormatVersion) throw new InvalidDataException($"{path} is newer than this Chronos.");
+ return renders;
+ }
+
+ /// Writes to whole and atomically, making its folder when needed.
+ /// The file cannot be written; the ledger there stays as it was.
+ public static void Write(string path, WorkspaceRenders renders)
+ {
+ ArgumentException.ThrowIfNullOrEmpty(path);
+ ArgumentNullException.ThrowIfNull(renders);
+ if (Path.GetDirectoryName(Path.GetFullPath(path)) is { Length: > 0 } folder) Directory.CreateDirectory(folder);
+ AtomicFile.WriteAllText(path, JsonSerializer.Serialize(renders with { Format = FormatName, FormatVersion = CurrentFormatVersion }, WorkspaceJson.Default.WorkspaceRenders));
+ }
+}
diff --git a/src/Chronos.Data/Workspaces/WorkspaceSendJobHandler.cs b/src/Chronos.Data/Workspaces/WorkspaceSendJobHandler.cs
new file mode 100644
index 00000000..2434dca6
--- /dev/null
+++ b/src/Chronos.Data/Workspaces/WorkspaceSendJobHandler.cs
@@ -0,0 +1,25 @@
+using Chronos.Core.Model;
+using Chronos.Data.Archiving;
+using Chronos.Data.Jobs;
+using Chronos.Data.Sync;
+
+namespace Chronos.Data.Workspaces;
+
+///
+/// (phase 5c, ): the local renders of a workspace project
+/// sent home with their project and version, per unsent ledger entry: the file hashed again (another is refused and stays),
+/// the version it names pushed first when the home lacks it, then filed in this PC's archive (as the sync files a server's
+/// exports) or uploaded to its server (RenderUploadRequest with ProjectId and ProjectVersionId), and the
+/// entry marked sent. Idempotent by render id: a send repeated after a cut finds the home holding it already.
+///
+internal sealed class WorkspaceSendJobHandler(ChronosDatabase db, ArchiveService archives, ISyncConnector? servers, WorkspaceJobOptions options) : IJobHandler
+{
+ public JobKind Kind => JobKind.WorkspaceSend;
+
+ public Task RunAsync(JobContext context)
+ {
+ ArgumentNullException.ThrowIfNull(context);
+ _ = (db, archives, servers, options);
+ throw new NotImplementedException("Sending a workspace project's renders home comes with phase 5c (P3).");
+ }
+}
diff --git a/src/Chronos.Data/Workspaces/WorkspaceStore.cs b/src/Chronos.Data/Workspaces/WorkspaceStore.cs
index 03d455a5..78df8d9f 100644
--- a/src/Chronos.Data/Workspaces/WorkspaceStore.cs
+++ b/src/Chronos.Data/Workspaces/WorkspaceStore.cs
@@ -91,17 +91,48 @@ public sealed record WorkspaceConflict(Guid TheirsVersionId, int TheirsNumber, G
///
/// Parameters of a job: target = the home's sequence; the workspace folder, the
-/// project whose media to copy and what to copy (; originals in phase 5c).
+/// project whose media to copy and what to copy (, or :
+/// the proxies plus the originals, phase 5c).
///
/// The server the home's sequence is on (, phase 5b); null for a sequence of this PC's archive.
public sealed record WorkspaceCopyParameters(string WorkspaceRoot, Guid ProjectId, string Media, string? Server = null);
+///
+/// Parameters of a job (phase 5c): target = the home's sequence; the workspace folder,
+/// the project rendered from the originals its media hold, the version rendered (null: the head version the workspace
+/// holds), and the render's export settings as Protocol RenderJobParameters JSON (portable settings, preset,
+/// overrides, batch), as writes them for a render.
+///
+/// The version rendered and recorded with each output; null renders the head version the workspace holds.
+/// Protocol RenderJobParameters as JSON.
+/// The server the home's sequence is on (); null for a sequence of this PC's archive.
+public sealed record WorkspaceRenderParameters(string WorkspaceRoot, Guid ProjectId, Guid? ProjectVersionId, string RenderJson, string? Server = null);
+
+///
+/// Parameters of a job (phase 5c): target = the home's sequence; the workspace folder,
+/// the project, and the ledger entries () whose files go home.
+///
+/// The renders sent; empty sends every pending entry of the project's ledger.
+/// The server the home's sequence is on (); null for a sequence of this PC's archive.
+public sealed record WorkspaceSendParameters(string WorkspaceRoot, Guid ProjectId, IReadOnlyList RenderIds, string? Server = null);
+
+///
+/// Parameters of a job (phase 5c): no target; the workspace folder moved
+/// (), the folder it goes to, and the fingerprint of the plan the user confirmed (the job refuses a
+/// workspace that changed since).
+///
+public sealed record WorkspaceMoveParameters(string From, string To, string PlanFingerprint);
+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
UseStringEnumConverter = true, WriteIndented = true)]
[JsonSerializable(typeof(WorkspaceManifest))]
[JsonSerializable(typeof(WorkspaceMedia))]
[JsonSerializable(typeof(WorkspaceSyncState))]
[JsonSerializable(typeof(WorkspaceCopyParameters))]
+[JsonSerializable(typeof(WorkspaceRenderParameters))]
+[JsonSerializable(typeof(WorkspaceSendParameters))]
+[JsonSerializable(typeof(WorkspaceMoveParameters))]
+[JsonSerializable(typeof(WorkspaceRenders))]
internal sealed partial class WorkspaceJson : JsonSerializerContext;
///
@@ -309,9 +340,11 @@ public sealed class WorkspaceStore
///
/// One project in the workspace (owner review 2, R8): <root>/<project id>/ with
/// project.chronos (the working state: a project file of format 2, its settings placed on the media's frames),
-/// media/media.json with media/proxies/<frame id>.jpg (originals later) and media/analysis.json
-/// (the home's deep report), versions/<number>-<id>.json (commits not pushed yet, and the versions pulled),
-/// sync.json, exports/ and the lease .lock.lease that one writer at a time holds.
+/// media/media.json with media/proxies/<frame id>.jpg, media/originals/<frame id>-<sha8><ext>
+/// (media of kind originals, phase 5c) and media/analysis.json (the home's deep report),
+/// versions/<number>-<id>.json (commits not pushed yet, and the versions pulled), sync.json,
+/// exports/ with the local renders and their ledger exports/renders.json (phase 5c), and the lease
+/// .lock.lease that one writer at a time holds.
///
public sealed class WorkspaceProject
{
@@ -324,6 +357,12 @@ public sealed class WorkspaceProject
public const string ExportsFolder = "exports";
public const string SyncFile = "sync.json";
+ /// The name of the ledger of the project's local renders () in .
+ public const string RendersFileName = "renders.json";
+
+ /// The ledger of the project's local renders (phase 5c), relative to .
+ public const string RendersFile = ExportsFolder + "/" + RendersFileName;
+
///
/// Old local commits replaced by their replay on top of the home's head, files the home's copy replaced, and the working
/// states a take of the server's values replaced: kept up to a month, the newest 20 at most ().
@@ -365,6 +404,9 @@ public sealed class WorkspaceProject
public string ExportsDirectory => Path.Combine(Folder, ExportsFolder);
public string SyncPath => Path.Combine(Folder, SyncFile);
+ /// The ledger of the project's local renders (, phase 5c).
+ public string RendersPath => Path.Combine(ExportsDirectory, RendersFileName);
+
public bool Exists => File.Exists(BundlePath);
/// The file a frame's proxy is copied to, relative to .
@@ -380,9 +422,35 @@ public sealed class WorkspaceProject
return ProxiesFolder + "/" + frameId.ToString("N") + "-" + sha256[..Math.Min(16, sha256.Length)].ToLowerInvariant() + ".jpg";
}
+ ///
+ /// The file a frame's original is copied to, relative to (phase 5c):
+ /// originals/<frame id>-<sha8><ext>. The first 8 hex digits of its SHA-256 tell two encodings of one
+ /// frame apart (a conversion since: the editor keeps the one it reads until the copy commits), and the original's own
+ /// extension is kept, lower case, since decoders go by it.
+ ///
+ /// The original's extension, with or without its dot (".CR3", "dng", or the file name's ); empty or null for none.
+ public static string OriginalName(Guid frameId, string sha256, string? extension)
+ {
+ ArgumentException.ThrowIfNullOrEmpty(sha256);
+ var ext = (extension ?? string.Empty).Trim().TrimStart('.').ToLowerInvariant();
+ if (ext.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || ext.Contains('/') || ext.Contains('\\')) ext = string.Empty;
+ return OriginalsFolder + "/" + frameId.ToString("N") + "-" + sha256[..Math.Min(8, sha256.Length)].ToLowerInvariant() + (ext.Length > 0 ? "." + ext : string.Empty);
+ }
+
+ /// The ledger of the project's local renders; empty while it has none ().
+ /// The ledger is damaged or newer.
+ /// The ledger cannot be read.
+ public WorkspaceRenders ReadRenders() => WorkspaceRenders.Read(RendersPath);
+
+ /// Writes the ledger of the project's local renders whole and atomically (); the caller holds the project's lease.
+ public void WriteRenders(WorkspaceRenders renders) => WorkspaceRenders.Write(RendersPath, renders);
+
/// The absolute path of a file named relative to .
public string MediaFile(string relative) => LongPath.FromPortableRelative(MediaDirectory, relative);
+ /// The absolute path of a local render named relative to ().
+ public string ExportFile(string relative) => LongPath.FromPortableRelative(ExportsDirectory, relative);
+
/// Holds the project for one writer (this program's sync, a copy job) until disposed.
/// Another writer kept it for longer than .
public async Task LockAsync(TimeSpan wait, CancellationToken cancellationToken = default)
diff --git a/src/Chronos.Protocol/Uploads.cs b/src/Chronos.Protocol/Uploads.cs
index b0a2108d..14875b6a 100644
--- a/src/Chronos.Protocol/Uploads.cs
+++ b/src/Chronos.Protocol/Uploads.cs
@@ -46,6 +46,10 @@ public sealed record CardImportReport(Guid ImportId, string Card, string State,
/// and files the render under the sequence's exports. A completion that cannot file it for now answers 503
/// sequence_busy, archive_offline or folder_moved (another index moved the sequence's folder; the
/// server's next scan finds it) and keeps the upload, to be completed again.
+/// A render a workspace made on a client (phase 5c) names the project and version it was rendered from
+/// (, ): the server records them with the render once it checked that
+/// the project is the sequence's and the version the project's (422 project_mismatch otherwise). Both are optional
+/// and appended: a request of an earlier client has neither, and an earlier server ignores them.
///
public sealed record RenderUploadRequest(
Guid RenderId,
@@ -58,4 +62,6 @@ public sealed record RenderUploadRequest(
int Height,
double Fps,
double DurationSeconds,
- string? ProducedBy);
+ string? ProducedBy,
+ Guid? ProjectId = null,
+ Guid? ProjectVersionId = null);
diff --git a/tests/Chronos.App.Tests/Jobs/JobNoticesTests.cs b/tests/Chronos.App.Tests/Jobs/JobNoticesTests.cs
index 8d755a06..3e25a2ca 100644
--- a/tests/Chronos.App.Tests/Jobs/JobNoticesTests.cs
+++ b/tests/Chronos.App.Tests/Jobs/JobNoticesTests.cs
@@ -17,6 +17,9 @@ public sealed class JobNoticesTests
[Case(JobKind.Move)]
[Case(JobKind.Adopt)]
[Case(JobKind.Convert)]
+ [Case(JobKind.WorkspaceRender)]
+ [Case(JobKind.WorkspaceSend)]
+ [Case(JobKind.WorkspaceMove)]
public void ALongOperationThatEndsSaysSo(JobKind kind)
{
Assert.Equal(JobNotice.Done, JobNotices.For(JobState.Running, Job(kind, JobState.Done)));
diff --git a/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs b/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs
index 65cd8195..e438e123 100644
--- a/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs
+++ b/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs
@@ -75,6 +75,102 @@ public sealed class WorkspaceHostTests(TestContext context)
Assert.Empty(older.WorkspaceRecent);
}
+ [Test]
+ public void ThePhase5cWorkspaceSettingsHaveTheirDefaultsAndSurviveTheSettingsFile()
+ {
+ var fresh = new AppSettings();
+ Assert.Equal((100, BundleMedia.Proxies, true, 30, WorkspaceOpenPolicy.LastUsed),
+ (fresh.WorkspaceSizeLimitGb, fresh.WorkspaceDefaultMedia, fresh.WorkspaceVersionOnRender, fresh.WorkspaceCleanAfterDays, fresh.WorkspaceOpenProject));
+ Assert.Empty(fresh.WorkspaceOpened);
+
+ // A settings file of phase 5b gets them too.
+ var older = AppSettings.Parse("""{ "Theme": "Light", "WorkspaceKeptVersions": 50 }""")!;
+ Assert.Equal((100, BundleMedia.Proxies, true, 30, WorkspaceOpenPolicy.LastUsed, 50),
+ (older.WorkspaceSizeLimitGb, older.WorkspaceDefaultMedia, older.WorkspaceVersionOnRender, older.WorkspaceCleanAfterDays, older.WorkspaceOpenProject,
+ older.WorkspaceKeptVersions));
+ Assert.Empty(older.WorkspaceOpened);
+
+ var project = Guid.CreateVersion7();
+ var at = new DateTimeOffset(2026, 11, 4, 9, 30, 0, TimeSpan.FromHours(1));
+ var settings = new AppSettings
+ {
+ WorkspaceSizeLimitGb = 0,
+ WorkspaceDefaultMedia = BundleMedia.Originals,
+ WorkspaceVersionOnRender = false,
+ WorkspaceCleanAfterDays = 0,
+ WorkspaceOpenProject = WorkspaceOpenPolicy.Ask,
+ };
+ settings.WorkspaceOpened[project] = at;
+ var copy = AppSettings.Parse(settings.ToJson())!;
+ Assert.Equal((0, BundleMedia.Originals, false, 0, WorkspaceOpenPolicy.Ask),
+ (copy.WorkspaceSizeLimitGb, copy.WorkspaceDefaultMedia, copy.WorkspaceVersionOnRender, copy.WorkspaceCleanAfterDays, copy.WorkspaceOpenProject));
+ Assert.Equal(at, copy.WorkspaceOpened[project]);
+ Assert.Contains("\"Ask\"", settings.ToJson());
+ }
+
+ [Test]
+ public void WhenEachProjectWasOpenedStaysOnThisPc()
+ {
+ var project = Guid.CreateVersion7();
+ var sequence = Guid.CreateVersion7();
+ var at = new DateTimeOffset(2026, 11, 4, 9, 30, 0, TimeSpan.Zero);
+ var mine = new AppSettings { WorkspaceFolder = @"D:\Fast\Workspace", WorkspaceSizeLimitGb = 250, WorkspaceOpenProject = WorkspaceOpenPolicy.Main };
+ mine.WorkspaceRecent[sequence] = project;
+ mine.WorkspaceOpened[project] = at;
+
+ // Reset puts the preferences back and keeps what this PC knows of its projects.
+ var reset = mine.ResetKeepingState();
+ Assert.Equal((AppSettings.DefaultWorkspaceSizeLimitGb, WorkspaceOpenPolicy.LastUsed), (reset.WorkspaceSizeLimitGb, reset.WorkspaceOpenProject));
+ Assert.Equal((@"D:\Fast\Workspace", project, at), (reset.WorkspaceFolder, reset.WorkspaceRecent[sequence], reset.WorkspaceOpened[project]));
+
+ // Export carries the preferences, not this PC's projects.
+ var exported = AppSettings.Parse(mine.ForExport().ToJson())!;
+ Assert.Equal((250, WorkspaceOpenPolicy.Main, (string?)null), (exported.WorkspaceSizeLimitGb, exported.WorkspaceOpenProject, exported.WorkspaceFolder));
+ Assert.Empty(exported.WorkspaceOpened);
+ Assert.Empty(exported.WorkspaceRecent);
+ Assert.Equal(at, mine.WorkspaceOpened[project]);
+
+ // Import takes another PC's preferences and keeps this PC's projects.
+ var theirs = new AppSettings { WorkspaceSizeLimitGb = 40, WorkspaceFolder = @"E:\Elsewhere" };
+ theirs.WorkspaceOpened[Guid.CreateVersion7()] = at.AddDays(-3);
+ var imported = mine.KeepLocalIn(AppSettings.Parse(theirs.ToJson())!);
+ Assert.Equal((40, @"D:\Fast\Workspace"), (imported.WorkspaceSizeLimitGb, imported.WorkspaceFolder));
+ Assert.Equal(at, imported.WorkspaceOpened.Values.Single());
+ Assert.Count(1, imported.WorkspaceOpened);
+ }
+
+ [Test]
+ public void OpeningAProjectRecordsWhenAndSavesIt()
+ {
+ var local = context.CreateTempDirectory("local");
+ var installed = AppEnvironment.From(AppPaths.Resolve(context.CreateTempDirectory("app"), local, []));
+ var settings = new AppSettings();
+ var saves = 0;
+ var host = new WorkspaceHost(installed, settings, () => saves++, () => null, () => null, () => null);
+ var project = Guid.CreateVersion7();
+ var at = new DateTimeOffset(2026, 11, 4, 10, 0, 0, TimeSpan.Zero);
+ host.RecordOpened(project, at);
+ Assert.Equal((at, 1), (settings.WorkspaceOpened[project], saves));
+ host.RecordOpened(project);
+ Assert.True(settings.WorkspaceOpened[project] > at, "opened again later");
+ Assert.Equal(2, saves);
+ Assert.False(host.IsMoving);
+ }
+
+ [Test]
+ public void AProjectWithRendersNotSentIsNotSafeToRemoveAndOriginalsNeedTheirRoom()
+ {
+ var plan = new WorkspaceRemovalPlan(Guid.CreateVersion7(), "Main", 12, 1_000, 0, false, false, false);
+ Assert.True(plan.IsSafe);
+ Assert.False((plan with { UnsentRenders = 1 }).IsSafe);
+ Assert.True((plan with { LastOriginals = 3 }).IsSafe, "the last originals go to the trash, never deleted");
+
+ var facts = new WorkspaceCopyFacts(1_000, 1_000 + WorkspaceJobs.CopySpaceReserve + 500, 2_000);
+ Assert.False(facts.TooLittleSpaceFor(BundleMedia.Proxies));
+ Assert.True(facts.TooLittleSpaceFor(BundleMedia.Originals));
+ Assert.False((facts with { Free = null }).TooLittleSpaceFor(BundleMedia.Originals), "a drive whose room is unknown is tried");
+ }
+
[Test]
public void SettingsWorkspaceRowsStoreEachChoiceAtOnce()
{
diff --git a/tests/Chronos.Data.Tests/Jobs/JobPriorityQueueTests.cs b/tests/Chronos.Data.Tests/Jobs/JobPriorityQueueTests.cs
index 9f87aa39..e090f2d6 100644
--- a/tests/Chronos.Data.Tests/Jobs/JobPriorityQueueTests.cs
+++ b/tests/Chronos.Data.Tests/Jobs/JobPriorityQueueTests.cs
@@ -30,6 +30,30 @@ public sealed class JobPriorityQueueTests
Assert.Equal(JobKindPriority.Low, (queue with { Levels = new Dictionary { [JobKind.Render] = JobKindPriority.Low } }).LevelOf(JobKind.Render));
}
+ [Test]
+ public void ALocalRenderAndAWorkspaceMoveGoFirstAndSendingARenderHomeWaitsItsTurn()
+ {
+ var queue = new JobPriorityQueue();
+ // The user waits on a local render as on a render, and Edit is held while the workspace moves.
+ Assert.Equal(JobKindPriority.High, queue.LevelOf(JobKind.WorkspaceRender));
+ Assert.Equal(JobKindPriority.High, queue.LevelOf(JobKind.WorkspaceMove));
+ Assert.Equal(JobKindPriority.Normal, queue.LevelOf(JobKind.WorkspaceSend));
+ var on = queue with { Enabled = true };
+ Assert.True(on.Interrupts(JobKind.WorkspaceRender, JobKind.WorkspaceSend));
+ Assert.False(on.Interrupts(JobKind.WorkspaceSend, JobKind.Scan));
+ // The defaults are no change: settings store none of them, and read back as they are.
+ var defaults = new Dictionary
+ {
+ [JobKind.WorkspaceRender] = JobKindPriority.High,
+ [JobKind.WorkspaceSend] = JobKindPriority.Normal,
+ [JobKind.WorkspaceMove] = JobKindPriority.High,
+ };
+ Assert.Empty(JobPriorityQueue.Changed(defaults));
+ var changed = JobPriorityQueue.Changed(new Dictionary { [JobKind.WorkspaceSend] = JobKindPriority.Low });
+ Assert.Equal("low", changed["workspace-send"]);
+ Assert.Equal(JobKindPriority.Low, JobPriorityQueue.From(true, changed).LevelOf(JobKind.WorkspaceSend));
+ }
+
[Test]
public void OnlyAHigherLevelInterruptsAndOnlyWhileTheQueueIsOn()
{
diff --git a/tests/Chronos.Data.Tests/Jobs/JobWireTests.cs b/tests/Chronos.Data.Tests/Jobs/JobWireTests.cs
new file mode 100644
index 00000000..b4262c31
--- /dev/null
+++ b/tests/Chronos.Data.Tests/Jobs/JobWireTests.cs
@@ -0,0 +1,31 @@
+using Chronos.Core.Model;
+using Chronos.Data.Jobs;
+using Chronos.Testing;
+
+namespace Chronos.Data.Tests.Jobs;
+
+/// The names the jobs' kinds carry on the wire and in settings (BRIEF §14.6): stable once shipped.
+[Category("jobs")]
+public sealed class JobWireTests
+{
+ [Theory]
+ [Case(JobKind.WorkspaceCopy, 20, "workspace-copy")]
+ [Case(JobKind.WorkspaceRender, 21, "workspace-render")]
+ [Case(JobKind.WorkspaceSend, 22, "workspace-send")]
+ [Case(JobKind.WorkspaceMove, 23, "workspace-move")]
+ public void TheWorkspaceJobsKeepTheirValueAndName(JobKind kind, int value, string name)
+ {
+ Assert.Equal(value, (int)kind);
+ Assert.Equal(name, JobWire.Kind(kind));
+ Assert.True(JobWire.TryParseKind(name, out var parsed), name);
+ Assert.Equal(kind, parsed);
+ }
+
+ [Test]
+ public void EveryKindHasItsOwnName()
+ {
+ var names = Enum.GetValues().Select(JobWire.Kind).ToList();
+ Assert.Equal(names.Count, names.Distinct(StringComparer.Ordinal).Count());
+ Assert.False(JobWire.TryParseKind("workspace-teleport", out _));
+ }
+}
diff --git a/tests/Chronos.Data.Tests/Workspaces/WorkspaceFoundationTests.cs b/tests/Chronos.Data.Tests/Workspaces/WorkspaceFoundationTests.cs
new file mode 100644
index 00000000..ec9907f2
--- /dev/null
+++ b/tests/Chronos.Data.Tests/Workspaces/WorkspaceFoundationTests.cs
@@ -0,0 +1,211 @@
+using System.Text.Json.Nodes;
+using Chronos.Core.Model;
+using Chronos.Core.Project;
+using Chronos.Data.Archiving.Jobs;
+using Chronos.Data.Jobs;
+using Chronos.Data.Tests.Archiving;
+using Chronos.Data.Tests.Infrastructure;
+using Chronos.Data.Workspaces;
+using Chronos.Testing;
+
+namespace Chronos.Data.Tests.Workspaces;
+
+///
+/// The shared types of phase 5c (owner review 2, R8): originals in the media index, the ledger of local renders, the names
+/// of the workspace's files, and the jobs of the workspace with their parameters.
+///
+[Category("workspace")]
+public sealed class WorkspaceFoundationTests(TestContext context)
+{
+ private static readonly DateTimeOffset T0 = new(2026, 11, 4, 9, 0, 0, TimeSpan.Zero);
+
+ private static WorkspaceMedia Media(Guid sequenceId, string kind, params WorkspaceFrame[] frames) =>
+ new(WorkspaceMedia.FormatName, WorkspaceMedia.CurrentFormatVersion, kind, sequenceId, 3, frames, T0);
+
+ private static WorkspaceFrame Frame(Guid sequenceId, int index) =>
+ WorkspaceFrame.Of(TestData.Frame(sequenceId, index), $"proxies/{Guid.NewGuid():N}.jpg", new string('a', 64), 1_500_000);
+
+ [Test]
+ public void AMediaIndexOfPhase5bReadsAsProxiesWithoutOriginals()
+ {
+ var store = new WorkspaceStore(Path.Combine(context.CreateTempDirectory("ws"), "workspace"));
+ var project = store.Project(Guid.CreateVersion7());
+ var sequenceId = Guid.CreateVersion7();
+ project.WriteMedia(Media(sequenceId, BundleMedia.Proxies, Frame(sequenceId, 0), Frame(sequenceId, 1)));
+
+ // As phase 5b wrote it: no original fields at all.
+ var json = JsonNode.Parse(File.ReadAllText(project.MediaIndexPath))!.AsObject();
+ foreach (var frame in json["frames"]!.AsArray())
+ {
+ var fields = frame!.AsObject();
+ foreach (var name in new[] { "original", "originalSha256", "originalBytes" }) fields.Remove(name);
+ }
+ File.WriteAllText(project.MediaIndexPath, json.ToJsonString());
+ Assert.False(File.ReadAllText(project.MediaIndexPath).Contains("\"original\"", StringComparison.Ordinal), "no original field is left");
+
+ var media = Assert.NotNull(project.ReadMedia());
+ Assert.Equal(BundleMedia.Proxies, media.Kind);
+ Assert.False(media.HoldsOriginals);
+ foreach (var frame in media.Frames)
+ {
+ Assert.Equal(((string?)null, (string?)null, 0L, false), (frame.Original, frame.OriginalSha256, frame.OriginalBytes, frame.HasOriginal));
+ // A render from originals finds none: every frame is missing there, while the editor reads its proxy.
+ Assert.True(frame.ToOriginalFrame(sequenceId).Flags.HasFlag(FrameFlags.Missing));
+ Assert.False(frame.ToFrame(sequenceId).Flags.HasFlag(FrameFlags.Missing));
+ }
+ }
+
+ [Test]
+ public void OriginalsInTheMediaIndexAreReadBackAndRenderedFrom()
+ {
+ var store = new WorkspaceStore(Path.Combine(context.CreateTempDirectory("ws"), "workspace"));
+ var project = store.Project(Guid.CreateVersion7());
+ var sequenceId = Guid.CreateVersion7();
+ var held = Frame(sequenceId, 0);
+ var sha = new string('c', 64);
+ var original = WorkspaceProject.OriginalName(held.Id, sha, Path.GetExtension(held.FileName));
+ held = held with { Original = original, OriginalSha256 = sha, OriginalBytes = held.Size };
+ var proxied = Frame(sequenceId, 1);
+ project.WriteMedia(Media(sequenceId, BundleMedia.Originals, held, proxied));
+
+ var media = Assert.NotNull(project.ReadMedia());
+ Assert.True(media.HoldsOriginals);
+ Assert.Equal((original, sha, held.Size), (media.Frames[0].Original, media.Frames[0].OriginalSha256, media.Frames[0].OriginalBytes));
+ var frames = media.ToOriginalFrames();
+ Assert.Equal(original, frames[0].RelativePath);
+ Assert.False(frames[0].Flags.HasFlag(FrameFlags.Missing));
+ // A frame whose original the home lacked stays a proxy for the editor and is missing for a local render.
+ Assert.True(frames[1].Flags.HasFlag(FrameFlags.Missing));
+ Assert.Equal(proxied.File, media.ToFrames()[1].RelativePath);
+ Assert.Equal(Path.Combine(project.OriginalsDirectory, Path.GetFileName(original)), project.MediaFile(original));
+ }
+
+ [Test]
+ public void OriginalsKeepTheirExtensionAndAShortHashInTheirName()
+ {
+ var id = Guid.Parse("0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a01");
+ var sha = "ABCDEF0123456789" + new string('0', 48);
+ Assert.Equal("originals/0192a4c17b3e7cc08a512f9d0e6b1a01-abcdef01.cr3", WorkspaceProject.OriginalName(id, sha, ".CR3"));
+ Assert.Equal("originals/0192a4c17b3e7cc08a512f9d0e6b1a01-abcdef01.dng", WorkspaceProject.OriginalName(id, sha, "dng"));
+ Assert.Equal("originals/0192a4c17b3e7cc08a512f9d0e6b1a01-abcdef01", WorkspaceProject.OriginalName(id, sha, null));
+ Assert.Equal("originals/0192a4c17b3e7cc08a512f9d0e6b1a01-abcdef01", WorkspaceProject.OriginalName(id, sha, "a/b"));
+ Assert.Throws(() => WorkspaceProject.OriginalName(id, string.Empty, ".jpg"));
+
+ var store = new WorkspaceStore(Path.Combine(context.CreateTempDirectory("ws"), "workspace"));
+ var project = store.Project(id);
+ Assert.Equal("exports/renders.json", WorkspaceProject.RendersFile);
+ Assert.Equal(Path.Combine(project.Folder, "exports", "renders.json"), project.RendersPath);
+ Assert.Equal(Path.Combine(project.ExportsDirectory, "Roof 4K.mp4"), project.ExportFile("Roof 4K.mp4"));
+ }
+
+ private static WorkspaceRenderEntry Entry(Guid projectId, string file) =>
+ new(Guid.CreateVersion7(), Guid.CreateVersion7(), file, new string('b', 64), 12_345, "4K HEVC", "hevc", 3840, 2160, 30, 10, projectId,
+ Guid.CreateVersion7(), "hash", T0);
+
+ [Test]
+ public void TheLedgerOfLocalRendersIsWrittenWholeAndReadBack()
+ {
+ var store = new WorkspaceStore(Path.Combine(context.CreateTempDirectory("ws"), "workspace"));
+ var project = store.Project(Guid.CreateVersion7());
+ // No ledger yet: no renders.
+ Assert.Empty(project.ReadRenders().Entries);
+ Assert.Same(WorkspaceRenders.Empty, project.ReadRenders());
+
+ var first = Entry(project.ProjectId, "Roof 4K.mp4");
+ var second = Entry(project.ProjectId, "Roof 1080p.mp4") with { ProjectVersionId = null, SettingsHash = null };
+ var ledger = WorkspaceRenders.Empty.With(first).With(second);
+ project.WriteRenders(ledger);
+ Assert.FileExists(project.RendersPath);
+ Assert.Empty(Directory.GetFiles(project.ExportsDirectory, "*.tmp"));
+
+ var read = project.ReadRenders();
+ Assert.Equal((WorkspaceRenders.FormatName, 1, 2), (read.Format, read.FormatVersion, read.Entries.Count));
+ Assert.Equal(first, read.Entries[0]);
+ Assert.Equal(second, read.Entries[1]);
+ Assert.Equal(WorkspaceRenderEntry.Pending, read.Entries[0].State);
+ Assert.Count(2, read.Unsent);
+ Assert.Contains("\"state\": \"pending\"", File.ReadAllText(project.RendersPath));
+
+ // One entry per render id: a send that went home replaces it, a second time changes nothing.
+ var sent = read.With(first.AsSent(T0.AddMinutes(5)));
+ Assert.Count(2, sent.Entries);
+ Assert.True(Assert.NotNull(sent.Find(first.RenderId)).IsSent);
+ Assert.True(sent.Entries.SequenceEqual(sent.With(first.AsSent(T0.AddMinutes(5))).Entries), "the same send twice changes nothing");
+ Assert.True(sent.Unsent.Select(e => e.RenderId).SequenceEqual([second.RenderId]), "only the render not sent is unsent");
+ var failed = sent.With(second.AsFailed("The library cannot be reached now."));
+ Assert.Equal((WorkspaceRenderEntry.Failed, "The library cannot be reached now."), (failed.Find(second.RenderId)!.State, failed.Find(second.RenderId)!.Error));
+ Assert.True(failed.Find(second.RenderId)!.IsUnsent, "a failed send is sent again");
+ Assert.Count(1, failed.Without(first.RenderId).Entries);
+ Assert.Null(failed.Find(Guid.NewGuid()));
+
+ project.WriteRenders(failed);
+ Assert.True(failed.Entries.SequenceEqual(project.ReadRenders().Entries), "the ledger reads back as written");
+ }
+
+ [Test]
+ public void ALedgerDamagedOrOfANewerChronosIsRefused()
+ {
+ var store = new WorkspaceStore(Path.Combine(context.CreateTempDirectory("ws"), "workspace"));
+ var project = store.Project(Guid.CreateVersion7());
+ Directory.CreateDirectory(project.ExportsDirectory);
+ File.WriteAllText(project.RendersPath, "{ \"format\": \"chronos-workspace-renders\", \"formatVersion\": 1, \"entries\": [ { \"renderId\": ");
+ Assert.Throws(() => project.ReadRenders());
+ File.WriteAllText(project.RendersPath, """{ "format": "something-else", "formatVersion": 1, "entries": [] }""");
+ Assert.Throws(() => project.ReadRenders());
+ File.WriteAllText(project.RendersPath, """{ "format": "chronos-workspace-renders", "formatVersion": 2, "entries": [] }""");
+ Assert.Throws(() => project.ReadRenders());
+ // A state a later Chronos wrote counts as not sent: its file is never cleaned up.
+ var entry = Entry(project.ProjectId, "Roof.mp4") with { State = "queued-elsewhere" };
+ project.WriteRenders(WorkspaceRenders.Empty.With(entry));
+ Assert.True(project.ReadRenders().Entries.Single().IsUnsent);
+ }
+
+ [Test]
+ public void TheWorkspaceJobsCarryTheirParameters()
+ {
+ var sequenceId = Guid.CreateVersion7();
+ var projectId = Guid.CreateVersion7();
+ var versionId = Guid.CreateVersion7();
+ var root = Path.Combine(context.CreateTempDirectory("ws"), "workspace");
+
+ var render = WorkspaceJobs.Render(sequenceId, "Roof", root, projectId, versionId, """{ "presetName": "4K HEVC" }""", "https://studio:8443");
+ Assert.Equal((JobKind.WorkspaceRender, "Roof", JobPriority.User), (render.Kind, render.Label, render.Priority));
+ Assert.True(render.Targets.SequenceEqual([sequenceId]), "the render targets its sequence");
+ var rendered = Assert.NotNull(WorkspaceJobs.RenderParameters(Job(render)));
+ Assert.Equal(new WorkspaceRenderParameters(root, projectId, versionId, """{ "presetName": "4K HEVC" }""", "https://studio:8443"), rendered);
+
+ var ids = new[] { Guid.CreateVersion7(), Guid.CreateVersion7() };
+ var send = WorkspaceJobs.Send(sequenceId, "Roof", root, projectId, ids);
+ Assert.Equal((JobKind.WorkspaceSend, JobPriority.User), (send.Kind, send.Priority));
+ var sending = Assert.NotNull(WorkspaceJobs.SendParameters(Job(send)));
+ Assert.Equal((root, projectId, (string?)null), (sending.WorkspaceRoot, sending.ProjectId, sending.Server));
+ Assert.True(sending.RenderIds.SequenceEqual(ids), "the send names its renders");
+
+ var target = Path.Combine(context.CreateTempDirectory("fast"), "workspace");
+ var move = WorkspaceJobs.Move(root, target, "fingerprint");
+ Assert.Equal((JobKind.WorkspaceMove, target, 0), (move.Kind, move.Label, move.Targets.Count));
+ Assert.Equal(new WorkspaceMoveParameters(root, target, "fingerprint"), WorkspaceJobs.MoveParameters(Job(move)));
+
+ // Parameters of another kind, or none that read, are none.
+ Assert.Null(WorkspaceJobs.RenderParameters(Job(send)));
+ Assert.Null(WorkspaceJobs.MoveParameters(Job(move) with { ParametersJson = "{" }));
+ Assert.Equal(BundleMedia.Originals, WorkspaceJobs.CopyParameters(Job(WorkspaceJobs.CopyFromServer(sequenceId, "Roof", "https://studio:8443", root,
+ projectId, BundleMedia.Originals)))!.Media);
+ Assert.Throws(() => WorkspaceJobs.Move(root, target, " "));
+
+ static Job Job(ArchiveJobRequest request) => TestData.Job(request.Kind) with { TargetIds = request.Targets, ParametersJson = request.ParametersJson };
+ }
+
+ [Test]
+ public async Task TheWorkspaceRegistersAHandlerForEachOfItsJobs()
+ {
+ await using var archive = await ArchiveFixture.CreateAsync(context);
+ var kinds = new[] { JobKind.WorkspaceCopy, JobKind.WorkspaceRender, JobKind.WorkspaceSend, JobKind.WorkspaceMove };
+ var handlers = WorkspaceJobs.CreateHandlers(archive.Db, archive.Service, null, WorkspaceJobOptionsFor());
+ Assert.True(handlers.Select(h => h.Kind).SequenceEqual(kinds), string.Join(", ", handlers.Select(h => h.Kind)));
+ // The overloads of phase 5b register them all too.
+ Assert.True(WorkspaceJobs.CreateHandlers(archive.Db, archive.Service).Select(h => h.Kind).SequenceEqual(kinds), "the earlier overload");
+
+ static WorkspaceJobOptions WorkspaceJobOptionsFor() => new(new Chronos.Data.Processing.ProcessingOptions(), () => false);
+ }
+}
diff --git a/tests/Chronos.Server.Tests/Storage/UploadTests.cs b/tests/Chronos.Server.Tests/Storage/UploadTests.cs
index 2d4afee5..714ca766 100644
--- a/tests/Chronos.Server.Tests/Storage/UploadTests.cs
+++ b/tests/Chronos.Server.Tests/Storage/UploadTests.cs
@@ -341,6 +341,25 @@ public sealed class UploadTests(TestContext context)
Assert.Equal("cancelled", (await state.ReadAsync(ProtocolJson.Default.UploadState)).State);
}
+ [Test]
+ public void ARenderOfferOfAnEarlierClientReadsWithoutItsProjectAndAWorkspaceOneKeepsIt()
+ {
+ // As a client of phase 5b sends it: no project, no version.
+ var earlier = System.Text.Json.JsonSerializer.Deserialize("""
+ { "renderId": "0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a01", "fileName": "Roof.mp4", "size": 10, "sha256": "ab", "presetName": "4K HEVC",
+ "codec": "hevc", "width": 3840, "height": 2160, "fps": 30, "durationSeconds": 10 }
+ """, ProtocolJson.Default.RenderUploadRequest);
+ Assert.NotNull(earlier);
+ Assert.Equal(("Roof.mp4", (Guid?)null, (Guid?)null), (earlier.FileName, earlier.ProjectId, earlier.ProjectVersionId));
+ var omitted = System.Text.Json.JsonSerializer.Serialize(earlier, ProtocolJson.Default.RenderUploadRequest);
+ Assert.False(omitted.Contains("projectId", StringComparison.Ordinal), "an offer without a project names none");
+
+ var workspace = earlier with { ProjectId = Guid.CreateVersion7(), ProjectVersionId = Guid.CreateVersion7() };
+ var json = System.Text.Json.JsonSerializer.Serialize(workspace, ProtocolJson.Default.RenderUploadRequest);
+ Assert.Contains("\"projectVersionId\"", json);
+ Assert.Equal(workspace, System.Text.Json.JsonSerializer.Deserialize(json, ProtocolJson.Default.RenderUploadRequest));
+ }
+
/// Reports synchronously (Progress<T> posts to the thread pool and may arrive late).
private sealed class SyncProgress(Action report) : IProgress
{