diff --git a/Chronos.slnx b/Chronos.slnx index 58d06039..a81cf613 100644 --- a/Chronos.slnx +++ b/Chronos.slnx @@ -5,6 +5,7 @@ + diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index 898fcb85..98104d1c 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -10,7 +10,8 @@ COPY src/Chronos.Core/ src/Chronos.Core/ COPY src/Chronos.Data/ src/Chronos.Data/ COPY src/Chronos.Protocol/ src/Chronos.Protocol/ COPY src/Chronos.Server/ src/Chronos.Server/ -RUN dotnet publish src/Chronos.Server/Chronos.Server.csproj \ +COPY src/Chronos.Server.Host/ src/Chronos.Server.Host/ +RUN dotnet publish src/Chronos.Server.Host/Chronos.Server.Host.csproj \ -c Release -a "$TARGETARCH" --no-self-contained \ -p:ChronosVersion="$CHRONOS_VERSION" -o /out \ && rm -f /out/*.pdb @@ -43,5 +44,5 @@ RUN chmod 0755 /usr/local/bin/chronos-entrypoint && mkdir -p /archive /data /vid VOLUME ["/archive", "/data"] EXPOSE 8080 8443 HEALTHCHECK --interval=30s --timeout=8s --start-period=40s --retries=3 \ - CMD ["dotnet", "/app/Chronos.Server.dll", "--healthcheck"] + CMD ["dotnet", "/app/Chronos.Server.Host.dll", "--healthcheck"] ENTRYPOINT ["/usr/local/bin/chronos-entrypoint"] diff --git a/deploy/docker/entrypoint.sh b/deploy/docker/entrypoint.sh index 2bd812cd..5575060b 100755 --- a/deploy/docker/entrypoint.sh +++ b/deploy/docker/entrypoint.sh @@ -14,7 +14,7 @@ umask 002 # Help and the health probe touch neither folder. case "${1:-}" in - --help | -h | -\? | /\? | --healthcheck) exec dotnet /app/Chronos.Server.dll "$@" ;; + --help | -h | -\? | /\? | --healthcheck) exec dotnet /app/Chronos.Server.Host.dll "$@" ;; esac as_user() { @@ -62,7 +62,7 @@ if [ "$(id -u)" = "0" ]; then fi fi fi - exec setpriv --reuid="$PUID" --regid="$PGID" --clear-groups -- dotnet /app/Chronos.Server.dll "$@" + exec setpriv --reuid="$PUID" --regid="$PGID" --clear-groups -- dotnet /app/Chronos.Server.Host.dll "$@" fi -exec dotnet /app/Chronos.Server.dll "$@" +exec dotnet /app/Chronos.Server.Host.dll "$@" diff --git a/i18n/en/Admin.resx b/i18n/en/Admin.resx index 08b9c1ad..345d97bc 100644 --- a/i18n/en/Admin.resx +++ b/i18n/en/Admin.resx @@ -869,6 +869,7 @@ Warning Limits and retention Set by the environment variable {0}; remove the variable to change it here + Set in Chronos Desktop; change it in Settings on the PC that shares this library File level Least severe level written to the log files; Debug and Trace help find problems but fill the files fast File size (MB) diff --git a/i18n/en/Archive.resx b/i18n/en/Archive.resx index 3cb381b3..77fb1442 100644 --- a/i18n/en/Archive.resx +++ b/i18n/en/Archive.resx @@ -291,6 +291,7 @@ Restore database… Run maintenance Trash… + {0} (server)the name of the archive of a server's downloaded originals; {0} the server's name {0:N0} issue {0:N0} issues The orphan search stoppedlong diff --git a/i18n/en/Errors.resx b/i18n/en/Errors.resx index 5c16556f..da8fa47a 100644 --- a/i18n/en/Errors.resx +++ b/i18n/en/Errors.resx @@ -9,6 +9,8 @@ The archive could not be opened.long The current index could not be backed up or replaced; the restore runs again at the next start.long This backup cannot be restored; choose another one.long + {0} presents the ID of {1} with another certificate; check that it is not a copy of that server.{0} the server's name now, {1} the name it had + The folders could not be sorted: {0}. Nothing was deleted; Chronos tries again at the next start.{0} the reason Enter a number from {0} to {1}. Enter a whole number from {0} to {1}. Enter a folder. @@ -27,6 +29,10 @@ The sequence to render is no longer in the archive. Enter a server address such as nas.local:8443 or https://chronos.example.com. This file does not contain Chronos settings. + Sharing could not start: {0} + Open or create an archive before sharing it. + The library is not open yet; sharing starts once it is. + Port {0} is used by another program. Choose another one in Settings › Server. This PC or the server changed the sequence again; compare and choose again. The disk needs {0} GB more for this download.{0} gigabytes missing {0} render is no longer on this PC; the others were sent.{0} count @@ -34,6 +40,7 @@ {0} did not arrive intact; download it again.{0} file name The sequence is no longer in this PC's archive index. Open or create an archive on this PC to receive the originals. + No folder could be made for the originals of {0}; check that the drive of this PC's archive can be written.{0} the server's name Not connected to this server; connect and retry the job. This sequence is not on the server yet; upload it first. No original reached the server: they are missing here or already in another server sequence. diff --git a/i18n/en/Server.resx b/i18n/en/Server.resx index 986c389d..61600f7d 100644 --- a/i18n/en/Server.resx +++ b/i18n/en/Server.resx @@ -85,6 +85,7 @@ Not found.long That address is not a Chronos Server.long The plan converts nothing: every photo is skipped or every sequence is blocked.long + This address is this PC's own shared library, already open here.long Change your password first.long The photo was deleted from the sequence while it was being uploaded, so it was not added.long {0} cannot be read, and without its hash other copies would not learn it was deleted; close the program using it or check its permissions, then try again.long @@ -136,6 +137,7 @@ Server Status {0} ms + Sharing off: nothing swept.long Uploads expired: {0}, files removed: {1}, records removed: {2}, tokens removed: {3}long: job log line Cancel Password @@ -199,6 +201,28 @@ Trail length Transitions WB smoothing + Addresses + Admin panel + Admin password + {0} client + {0} clients + {0} · {1} · {2} + Clients + Copy + Fingerprint + Hide + None + Ports + HTTPS {0} · HTTP {1} + Render node + Restart + Sharing settings + Show + Not started + Not shared + Sharing + Starting… + This library Sign out Connected Connecting… diff --git a/i18n/en/Settings.resx b/i18n/en/Settings.resx index 8619d1c8..5a0a26d3 100644 --- a/i18n/en/Settings.resx +++ b/i18n/en/Settings.resx @@ -178,12 +178,28 @@ testing… Reset section Search settings + Announce on LAN + Server cache Trusted certificates Default server + LAN discovery Forget: {0} + HTTP port + HTTPS port + Known servers None Offer this PC + Offline + Originals folder + Public HTTP port + Public HTTPS port Render node + Server ID + Sharing + Server data + Share this library + Library name + Signed in Clear Spilled frames and decoded thumbnails are deleted and rebuilt when needed. Originals, proxies and renders are not touched.long Clear the cache? @@ -206,11 +222,13 @@ Workspace folder changed Choose the workspace folderlong; folder picker title Folder + Home folders Kept versions Folder not changed Projects found: {0}{0} count of the projects the folder chosen holds Projects left: {0}{0} count of the projects the folder in use keeps Sync + This PC Use folder {0} version {0} versions diff --git a/i18n/en/Shell.resx b/i18n/en/Shell.resx index d9200b8f..e8b4e776 100644 --- a/i18n/en/Shell.resx +++ b/i18n/en/Shell.resx @@ -5,6 +5,13 @@ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Chronosinvariant + Server ID clash + {0} project moved{0} count + {0} projects moved{0} count + Originals folder made + Folders pending + Projects in use, or a workspace being moved, follow at the next start.long; toast message under Folders pending + Folders sorted Job finished {0} job finished {0} jobs finished diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index a1992e6a..b81501f7 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -708,6 +708,18 @@ Editors import, edit and render; only admins manage users Uploaders send photos; editing needs an editor Viewers browse and download + Open the admin panel in your browser to manage accounts; the browser warns once about the self-signed certificate: compare its fingerprint with the one here + Temporary password of the account admin; change it at the first sign-in, then this row goes + Programs that used this library in the last 5 minutes, and the render nodes online + Copy this address for the Uploader or another Chronos + Copy the fingerprint + Copy the temporary password + Clients see this fingerprint the first time they connect; it must match + The ports the shared library listens on + Try to start sharing again + Open Settings › Server to share this library + Show or hide the password + Whether other PCs and the Uploader can use this PC's library now Sign in; the token is stored encrypted for this Windows user · Enter Sign out; the token is removed from this PC Connection to the server @@ -780,10 +792,13 @@ Server Chronos connects to at start; changing it signs out · Enter applies, Esc reverts Zip the logs, a system and codec report, settings and recent failed jobs into a folder you choose; passwords, tokens and photos are left out How much of the end of each log file the diagnostics bundle includes + Announce this library to Chronos programs on the local network Open the data this portable copy kept beside it before it ran from OneDrive. Chronos no longer uses it and leaves it as it is Save every setting as JSON, without the session token File name of each frame, for example {date}_{time}_{n:0000}; the extension is added · Enter applies, Esc reverts Archive folders, for example {year}/{date} {camera}; a slash starts a subfolder · Enter applies, Esc reverts + Port the shared library listens on for HTTP (8080 by default); a change restarts sharing · Enter applies, Esc reverts + Port the shared library listens on for HTTPS (8443 by default); a change restarts sharing · Enter applies, Esc reverts Load settings from a JSON file; the session and the window layout stay as they are Open the Microsoft Store page of this free or paid extension; Re-detect after installing it While Chronos is in front, its interface runs ahead of the jobs so it stays fluid during renders and analyses @@ -806,7 +821,17 @@ Without this extension some formats are read only from their embedded preview, or not at all, on this PC Frames whose mean brightness is at most this share of white count as night (star fields, night presets) · Enter applies, Esc reverts Open the data folder in Explorer + Open the shared library's data folder in Explorer Show the workspace folder in Explorer + Port clients reach when a router forwards another port to this PC; empty: the one above · Enter applies, Esc reverts + This server's proxies, render-node files and staged imports, inside the cache folder + Servers this PC has signed in to, with the folders kept for each + Not signed in: its projects open from the workspace and wait to sync + Show this server's share of the cache in Explorer + Show the archive of this server's downloaded originals in Explorer + Where Download originals puts this server's photos, apart from this PC's archive + Identifies the server even when its address or name changes: {0}{0} the whole id + This PC is signed in to this server now Version, build, system, licence, third-party code Portable mode, logs, diagnostics, database backup and restore, reset Analysis width, night and star thresholds, deep analysis @@ -816,7 +841,7 @@ Session rules, verification, duplicates, after-import actions While Chronos is minimised or in the background, inserted cards, finished jobs and server messages also appear as Windows notifications Quality profile, memory budget, parallelism, encoders - Default server, render node, trusted certificates + Sharing, default server, render node, trusted certificates Cache folder, thumbnails in memory, cache limit Update check on start Where projects are edited on this PC: the folder, sync and versions kept @@ -845,6 +870,9 @@ Find a setting by name Encode a short synthetic clip with every encoder and report pass or fail and speed · about a minute Speed on the synthetic 1280×720 test clip + Certificate, server settings, partial uploads and logs of the shared library; its accounts are in the index and its backups + Other PCs and the Uploader on your network use this PC's library as a Chronos Server, while Chronos runs and you are signed in + The name clients see on sign-in and in LAN discovery; empty: this PC's name · Enter applies, Esc reverts Always the Microsoft software H.264 encoder; slower, identical everywhere Remember the folder and leave it as it is Stars per megapixel from which a night frame counts as a star field · Enter applies, Esc reverts @@ -902,6 +930,7 @@ Update the installed programs in place and apply the changes listed · your data is kept Collapse navigation to icons · Ctrl+B Show navigation names · Ctrl+B + Show the logs folder in Explorer: the log says which folder could not be sorted Pause the job shown; it continues from its checkpoint when resumed Stop the current job · it can be resumed later Add a folder to watch @@ -996,6 +1025,10 @@ 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 + Each home keeps its projects in its own folder inside the workspace + Open this home's folder in Explorer + Projects of sequences on {0}: {1}{0} the server's name, {1} the folder + Projects of sequences in this PC's archive: {0}{0} the folder 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 diff --git a/i18n/it/Admin.it.resx b/i18n/it/Admin.it.resx index 96ebc21d..bae94aee 100644 --- a/i18n/it/Admin.it.resx +++ b/i18n/it/Admin.it.resx @@ -862,6 +862,7 @@ Avviso Limiti e conservazione Impostato dalla variabile d'ambiente {0}; rimuovi la variabile per cambiarlo qui + Impostato in Chronos Desktop; cambialo nelle Impostazioni del PC che condivide questa libreria Livello file Livello minimo scritto nei file di log; Debug e Trace aiutano a trovare i problemi ma riempiono i file in fretta Dimensione file (MB) diff --git a/i18n/it/Archive.it.resx b/i18n/it/Archive.it.resx index 3fecf541..cea69074 100644 --- a/i18n/it/Archive.it.resx +++ b/i18n/it/Archive.it.resx @@ -285,6 +285,7 @@ Ripristina database… Esegui manutenzione Cestino… + {0} (server) {0:N0} problema {0:N0} problemi Ricerca degli orfani interrotta diff --git a/i18n/it/Errors.it.resx b/i18n/it/Errors.it.resx index 601bb54b..d7d36ff4 100644 --- a/i18n/it/Errors.it.resx +++ b/i18n/it/Errors.it.resx @@ -9,6 +9,8 @@ Impossibile aprire l'archivio. Non è stato possibile copiare o sostituire l'indice attuale; il ripristino riparte al prossimo avvio. Questa copia non si può ripristinare; scegline un'altra. + {0} presenta l'ID di {1} con un altro certificato; verifica che non sia una copia di quel server. + Non è stato possibile riordinare le cartelle: {0}. Non è stato eliminato nulla; Chronos riprova al prossimo avvio. Inserisci un numero da {0} a {1}. Inserisci un numero intero da {0} a {1}. Inserisci una cartella. @@ -27,6 +29,10 @@ La sequenza da renderizzare non è più nell'archivio. Inserisci l'indirizzo di un server, ad esempio nas.local:8443 o https://chronos.example.com. Questo file non contiene impostazioni di Chronos. + Impossibile avviare la condivisione: {0} + Apri o crea un archivio prima di condividerlo. + La libreria non è ancora aperta; la condivisione parte appena lo è. + La porta {0} è usata da un altro programma. Scegline un'altra in Impostazioni › Server. La sequenza è cambiata di nuovo su questo PC o sul server; confronta e scegli di nuovo. Al disco servono altri {0} GB per questo scaricamento. {0} render non è più su questo PC; gli altri sono stati inviati. @@ -34,6 +40,7 @@ {0} non è arrivato integro; scaricalo di nuovo. La sequenza non è più nell'indice dell'archivio di questo PC. Apri o crea un archivio su questo PC per ricevere gli originali. + Non è stato possibile creare una cartella per gli originali di {0}; verifica che il disco dell'archivio di questo PC sia scrivibile. Non connesso a questo server; collegati e riprova l'attività. Questa sequenza non è ancora sul server; caricala prima. Nessun originale è arrivato al server: mancano qui o sono già in un'altra sequenza del server. diff --git a/i18n/it/Server.it.resx b/i18n/it/Server.it.resx index 264fc26b..34e65705 100644 --- a/i18n/it/Server.it.resx +++ b/i18n/it/Server.it.resx @@ -83,6 +83,7 @@ Non trovato. Questo indirizzo non è un Chronos Server. Il piano non converte nulla: ogni foto è esclusa o ogni sequenza è bloccata. + Questo indirizzo è la libreria condivisa di questo PC, già aperta qui.long Cambia prima la password. La foto è stata eliminata dalla sequenza mentre veniva caricata, quindi non è stata aggiunta.long Impossibile leggere {0}: senza il suo hash le altre copie non saprebbero che è stato eliminato. Chiudi il programma che lo usa o controlla i permessi, poi riprova. @@ -134,6 +135,7 @@ Server Stato {0} ms + Condivisione spenta: nulla da ripulire.long Caricamenti scaduti: {0}, file rimossi: {1}, record rimossi: {2}, token rimossi: {3}long: job log line Annulla Password @@ -197,6 +199,28 @@ Lunghezza scie Transizioni Livellamento WB + Indirizzi + Pannello admin + Password admin + {0} client + {0} client + {0} · {1} · {2} + Client + Copia + Impronta + Nascondi + Nessuno + Porte + HTTPS {0} · HTTP {1} + Nodo di rendering + Riavvia + Impostazioni condivisione + Mostra + Non avviata + Non condivisa + In condivisione + Avvio… + Questa libreria Esci Connesso Connessione… diff --git a/i18n/it/Settings.it.resx b/i18n/it/Settings.it.resx index c0bc4322..ce776c93 100644 --- a/i18n/it/Settings.it.resx +++ b/i18n/it/Settings.it.resx @@ -175,12 +175,28 @@ in prova… Ripristina sezione Cerca impostazioni + Annuncia in LAN + Cache del server Certificati attendibili Server predefinito + Rilevamento LAN Dimentica: {0} + Porta HTTP + Porta HTTPS + Server noti Nessuno Offri questo PC + Non in linea + Cartella originali + Porta HTTP pubblica + Porta HTTPS pubblica Nodo di rendering + ID server + Condivisione + Dati server + Condividi questa libreria + Nome libreria + Connesso Svuota I fotogrammi temporanei e le miniature vengono eliminati e ricreati quando servono. Originali, proxy ed esportazioni restano intatti. Svuotare la cache? @@ -203,11 +219,13 @@ Cartella cambiata Scegli la cartella dello spazio di lavoro Cartella + Cartelle per origine Versioni tenute Cartella non cambiata Progetti trovati: {0} Progetti lasciati: {0} Sincronizzazione + Questo PC Usa cartella {0} versione {0} versioni diff --git a/i18n/it/Shell.it.resx b/i18n/it/Shell.it.resx index 0b51d68b..13b193e9 100644 --- a/i18n/it/Shell.it.resx +++ b/i18n/it/Shell.it.resx @@ -4,6 +4,13 @@ 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ID server in conflitto + {0} progetto spostato + {0} progetti spostati + Cartella originali creata + Cartelle in attesa + I progetti in uso, o uno spazio di lavoro in spostamento, seguono al prossimo avvio. + Cartelle riordinate Attività completata {0} attività completata {0} attività completate diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index e12845a4..30cadddb 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -779,6 +779,18 @@ Gli editor importano, modificano ed esportano; solo gli amministratori gestiscono gli utenti I caricatori inviano foto; per modificare serve un editor I visualizzatori sfogliano e scaricano + Apri il pannello admin nel browser per gestire gli account; il browser avvisa una volta del certificato autofirmato: confronta l'impronta con quella qui + Password temporanea dell'account admin; cambiala al primo accesso, poi questa riga sparisce + Programmi che hanno usato questa libreria negli ultimi 5 minuti, e i nodi di rendering online + Copia questo indirizzo per l'Uploader o un altro Chronos + Copia l'impronta + Copia la password temporanea + I client vedono questa impronta la prima volta che si connettono; deve coincidere + Le porte su cui ascolta la libreria condivisa + Riprova ad avviare la condivisione + Apri Impostazioni › Server per condividere questa libreria + Mostra o nascondi la password + Se altri PC e l'Uploader possono usare ora la libreria di questo PC Accedi; il token viene salvato cifrato per questo utente di Windows · Invio Esci; il token viene rimosso da questo PC Connessione al server @@ -851,10 +863,13 @@ Server a cui Chronos si connette all'avvio; cambiarlo chiude l'accesso · Invio applica, Esc annulla Comprime log, rapporto su sistema e codec, impostazioni e attività fallite di recente in una cartella a tua scelta; password, token e foto restano fuori Quanta parte finale di ogni file di log include il pacchetto di diagnostica + Annuncia questa libreria ai programmi Chronos della rete locale Apri i dati che questa copia portatile teneva accanto a sé prima di trovarsi in OneDrive. Chronos non li usa più e li lascia com'erano Salva tutte le impostazioni in JSON, senza il token di sessione Nome del file di ogni fotogramma, ad esempio {date}_{time}_{n:0000}; l'estensione viene aggiunta · Invio applica, Esc annulla Cartelle dell'archivio, ad esempio {year}/{date} {camera}; la barra crea una sottocartella · Invio applica, Esc annulla + Porta su cui la libreria condivisa ascolta in HTTP (8080 di default); cambiarla riavvia la condivisione · Invio applica, Esc annulla + Porta su cui la libreria condivisa ascolta in HTTPS (8443 di default); cambiarla riavvia la condivisione · Invio applica, Esc annulla Carica le impostazioni da un file JSON; la sessione e la disposizione della finestra restano invariate Apri la pagina del Microsoft Store di questa estensione, gratuita o a pagamento; dopo averla installata premi Rileva di nuovo Mentre Chronos è in primo piano, l'interfaccia ha la precedenza sulle attività e resta fluida durante rendering e analisi @@ -877,7 +892,17 @@ Senza questa estensione alcuni formati si leggono solo dall'anteprima incorporata, o per niente, su questo PC I fotogrammi con luminosità media al massimo pari a questa quota del bianco contano come notturni (campi stellari, preset notturni) · Invio applica, Esc annulla Apri la cartella dati in Esplora file + Apri in Esplora risorse la cartella dati della libreria condivisa Mostra la cartella dello spazio di lavoro in Esplora file + Porta che i client raggiungono quando un router inoltra un'altra porta a questo PC; vuoto: quella sopra · Invio applica, Esc annulla + Proxy, file del nodo di rendering e importazioni in attesa di questo server, dentro la cartella della cache + I server a cui questo PC ha effettuato l'accesso, con le cartelle tenute per ciascuno + Accesso non effettuato: i suoi progetti si aprono dallo spazio di lavoro e attendono la sincronizzazione + Mostra la parte della cache di questo server in Esplora file + Mostra l'archivio degli originali scaricati da questo server in Esplora file + Dove Scarica originali mette le foto di questo server, separate dall'archivio di questo PC + Identifica il server anche quando cambiano indirizzo o nome: {0} + Questo PC ha effettuato l'accesso a questo server ora Quando Chronos è ridotto a icona o in secondo piano, schede inserite, attività finite e messaggi del server compaiono anche come notifiche di Windows Versione, build, sistema, licenza, codice di terze parti Modalità portatile, log, diagnostica, backup e ripristino del database, valori predefiniti @@ -887,7 +912,7 @@ Lingua, tema, avvio, notifiche Regole delle sessioni, verifica, duplicati, azioni dopo l'importazione Profilo di qualità, memoria, parallelismo, encoder - Server predefinito, nodo di rendering, certificati attendibili + Condivisione, server predefinito, nodo di rendering, certificati attendibili Cartella della cache, miniature in memoria, limite della cache Controllo degli aggiornamenti all'avvio Dove si modificano i progetti su questo PC: cartella, sincronizzazione e versioni tenute @@ -916,6 +941,9 @@ Trova un'impostazione per nome Codifica una breve clip sintetica con ogni encoder e ne riporta esito e velocità · circa un minuto Velocità sulla clip di prova sintetica 1280×720 + Certificato, impostazioni del server, upload parziali e log della libreria condivisa; i suoi account sono nell'indice e nei suoi backup + Altri PC e l'Uploader della tua rete usano la libreria di questo PC come Chronos Server, finché Chronos è aperto e hai effettuato l'accesso + Il nome che i client vedono all'accesso e nel rilevamento LAN; vuoto: il nome di questo PC · Invio applica, Esc annulla Sempre l'encoder software H.264 di Microsoft; più lento, identico ovunque Ricorda la cartella e lasciala com'è Stelle per megapixel da cui un fotogramma notturno conta come campo stellare · Invio applica, Esc annulla @@ -937,6 +965,10 @@ 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 La cartella dello spazio di lavoro (meglio un disco veloce); Cambia ne usa un'altra, Sposta porta con sé i progetti + Ogni origine tiene i suoi progetti in una cartella propria dentro lo spazio di lavoro + Apri la cartella di questa origine in Esplora file + Progetti delle sequenze su {0}: {1} + Progetti delle sequenze nell'archivio di questo PC: {0} Il progetto che hai aperto per ultimo per la sequenza Il progetto Principale della sequenza, che ne tiene le impostazioni 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 @@ -999,6 +1031,7 @@ Aggiorna sul posto i programmi installati e applica le modifiche elencate · i tuoi dati restano Riduci la navigazione alle icone · Ctrl+B Mostra i nomi della navigazione · Ctrl+B + Mostra la cartella dei log in Esplora file: il log dice quale cartella non è stata riordinata Mette in pausa l'attività mostrata; quando la riprendi continua dal punto di ripresa Ferma l'attività in corso · potrai riprenderla Aggiungi una cartella da controllare diff --git a/src/Chronos.App/Chronos.App.csproj b/src/Chronos.App/Chronos.App.csproj index be99345b..855311af 100644 --- a/src/Chronos.App/Chronos.App.csproj +++ b/src/Chronos.App/Chronos.App.csproj @@ -13,8 +13,13 @@ + + + + + diff --git a/src/Chronos.App/DesignTime/SampleData.cs b/src/Chronos.App/DesignTime/SampleData.cs index ace1ca49..5a42e65f 100644 --- a/src/Chronos.App/DesignTime/SampleData.cs +++ b/src/Chronos.App/DesignTime/SampleData.cs @@ -69,6 +69,36 @@ public sealed class SampleData /// The server-only sequence whose proxies keeps on this PC (Sunrise over Superga). public Guid ProxiedSequenceId => _sunrise; + /// The certificate fingerprint of this PC's shared library in the captures. + public const string ShareFingerprint = "4F:0B:E2:91:7C:3A:D5:68:B0:1E:29:C7:83:5D:F4:A6:12:9E:7B:40:D8:6C:35:E1:A9:52:0F:BD:74:C3:86:2E"; + + /// Server › This library shared (owner review 5, #67): sample addresses, two clients, the temporary password. + public static void ShowShare(AppServices services) + { + ArgumentNullException.ThrowIfNull(services); + var pc = AppEnvironment.SamplePcName; + services.Share.ShowSample(ShareState.On, null, + [$"https://{pc}:8443", $"https://{pc}.studio.lan:8443", "https://192.168.1.20:8443", "https://100.88.14.3:8443"], 8443, 8080, ShareFingerprint, + "kT7p-Qm2x-Wf9r", [ + new ShareClient("anna", "Chronos Uploader (ANNA-LAPTOP)", "192.168.1.31", Now.AddMinutes(-1)), + new ShareClient("admin", Chronos.Server.Security.ClientActivity.AdminPanel, "127.0.0.1", Now.AddMinutes(-3)), + ]); + } + + /// Server › This library that could not start: the port is taken. + public static void ShowShareFailed(AppServices services) + { + ArgumentNullException.ThrowIfNull(services); + services.Share.ShowSample(ShareState.Failed, Loc.L("Errors.Share.PortInUse", 8443), [], 0, 0, null, null, []); + } + + /// Server › This library not shared, as before . + public static void HideShare(AppServices services) + { + ArgumentNullException.ThrowIfNull(services); + services.Share.ShowSample(ShareState.Off, null, [], 0, 0, null, null, []); + } + /// Points the services at fakes (server, encoders, update check) for an empty first-run state. public static SampleData Configure(AppServices services) { @@ -84,7 +114,7 @@ public sealed class SampleData services.CheckForUpdateAsync = _ => Task.FromResult(null); services.Devices.Dispose(); services.Devices = new SampleDeviceMonitor(); - services.Sync.RemoteFactory = (_, _, _) => sample._remote; + services.Sync.RemoteFactory = (_, _, _, _) => sample._remote; services.Sync.EditorFactory = (_, _, _) => sample._remote; // The schedules keep the sample's moment: nothing becomes due while the screenshots are taken. services.SchedulerTime = new FixedTime(Now); @@ -134,6 +164,16 @@ public sealed class SampleData settings.ProtectedToken = "sample-token"; settings.TrustedCertificates = [new TrustedCertificate { Fingerprint = ServerFingerprint, Server = "https://nas.local:8443", TrustedAt = new DateTimeOffset(2026, 9, 1, 9, 30, 0, TimeSpan.Zero) }]; settings.RecentServers = ["https://nas.local:8443"]; + // Settings › Server › Known servers (owner review 5): the sample's server, known by its id. + settings.KnownServers = + [ + new KnownServer + { + Id = Guid.Parse("5a3c1f0e-7d2b-4c8e-9f10-2b6d4e8a1c37"), Name = "Studio NAS", LastAddress = "https://nas.local:8443", Fingerprint = ServerFingerprint, + Aliases = [Chronos.Data.Sync.SyncService.ServerKey(new Uri("https://nas.local:8443"))], LastSeen = Now, + }, + ]; + _services.Sync.KnownServersChanged(); settings.RenderNodeOptIn = true; // The jobs sample shows a deep analysis that yielded to the render (owner review 1). settings.PriorityQueue = true; diff --git a/src/Chronos.App/Editor/ProjectFiles.cs b/src/Chronos.App/Editor/ProjectFiles.cs index e1436daa..49eb6313 100644 --- a/src/Chronos.App/Editor/ProjectFiles.cs +++ b/src/Chronos.App/Editor/ProjectFiles.cs @@ -74,7 +74,7 @@ public sealed class ProjectFiles(ShellViewModel shell) if (bundle.Workspace is { } workspace) { // A workspace's own working state opens as it is; a copy of one (saved elsewhere, another PC's) gives its project its settings. - var own = shell.Services.Workspace.Store.Find(workspace.ProjectId) is { } project + var own = shell.Services.Workspace.Find(workspace.ProjectId) is { } project && string.Equals(Path.GetFullPath(project.BundlePath), Path.GetFullPath(path), StringComparison.OrdinalIgnoreCase); await shell.Sequence.ShowAsync(sequence.Id, new ProjectRequest(sequence.Id, workspace.ProjectId), own ? null : editor => Apply(editor, bundle)); return; diff --git a/src/Chronos.App/Infrastructure/AppEnvironment.cs b/src/Chronos.App/Infrastructure/AppEnvironment.cs index d97520bf..4edd9582 100644 --- a/src/Chronos.App/Infrastructure/AppEnvironment.cs +++ b/src/Chronos.App/Infrastructure/AppEnvironment.cs @@ -44,6 +44,16 @@ public sealed class AppEnvironment public string LogDirectory => Path.Combine(DataDirectory, "logs"); public string CacheDirectory => Path.Combine(DataDirectory, "cache"); public string BackupDirectory => Path.Combine(DataDirectory, "backups"); + + /// The private folder of the server this PC runs while it shares its library: certificate, settings, uploads, logs. + public string ShareDirectory => Path.Combine(DataDirectory, "server"); + + /// The PC's name as the screens show it: a capture shows . + public string PcName => IsCapture ? SamplePcName : Environment.MachineName; + + /// The PC name captures show. + public const string SamplePcName = "STUDIO-PC"; + public string DatabasePath => Path.Combine(DataDirectory, AppPaths.DatabaseFileName); public string SettingsPath => Path.Combine(DataDirectory, AppPaths.SettingsFileName); diff --git a/src/Chronos.App/Infrastructure/AppServices.cs b/src/Chronos.App/Infrastructure/AppServices.cs index d87a7c8d..98da75b6 100644 --- a/src/Chronos.App/Infrastructure/AppServices.cs +++ b/src/Chronos.App/Infrastructure/AppServices.cs @@ -12,6 +12,7 @@ using Chronos.App.Workspace; using Chronos.Core.Archiving; using Chronos.Core.Diagnostics; using Chronos.Core.Export; +using Chronos.Core.IO; using Chronos.Core.Imaging; using Chronos.Core.Imaging.Decoders; using Chronos.Core.Model; @@ -21,6 +22,7 @@ using Chronos.Core.Windows.MediaFoundation; using Chronos.Core.Windows.Wic; using Chronos.Data; using Chronos.Data.Archiving; +using Chronos.Data.Homes; using Chronos.Data.Jobs; using Chronos.Data.Processing; using Chronos.Data.Scheduling; @@ -72,12 +74,15 @@ public sealed class AppServices : IAsyncDisposable // The editor's open and closed groups survive a restart (owner review 1, R3). Chronos.App.Editor.EditorSettings.Groups.Bind(settings.EditorGroups, saveSettings); _renderNode = new RenderNodeHost(StartRenderNode); + Share = new LibraryShare(this); ArchiveSetup = new EngineArchiveSetup(this); Sync = new SyncHost(this); ScheduleHost = new DesktopScheduleHost(settings, () => Database, () => Archives); Workspace = new WorkspaceHost(environment, settings, saveSettings, () => Database, () => Archives, () => Engine); // A server that keeps projects is the home of the workspace projects of its sequences (owner review 2, R8, phase 5b). Workspace.ServerHomes = Sync.ProjectHome; + // A server home's folder is named by its server's id, whichever address reached it (owner review 5, #66). + Workspace.Identity = () => Sync.Identity; Sync.ProjectChanged += Workspace.OnServerProjectChanged; Server = new ServerSession(settings, saveSettings, new ChronosServerApiFactory(), new DpapiTokenProtector()); Encoders = new MediaFoundationInventory(); @@ -110,6 +115,7 @@ public sealed class AppServices : IAsyncDisposable { if (_server is not null) _server.PropertyChanged -= OnServerChanged; _server = value; + _server.IsOwnLibrary = Share.IsOwn; _server.PropertyChanged += OnServerChanged; UpdateRenderNode(); Sync.Update(); @@ -119,6 +125,9 @@ public sealed class AppServices : IAsyncDisposable /// Sync with the signed-in server: engine, job connection, background comparison. public SyncHost Sync { get; } + /// Settings › Server › Share this library: this PC's library served to the LAN while Chronos runs (owner review 5, #67). + public LibraryShare Share { get; } + /// /// A job of this PC moved a sequence's folder or changed its title or file names (a Reorganize step), or replaced its /// frames' files (a conversion), with the sequence's id (any thread): an open editor reads it again where and as it is now. @@ -151,6 +160,12 @@ public sealed class AppServices : IAsyncDisposable /// How the restore staged in Settings › Advanced went when the index opened; null when none was staged. public StagedRestoreResult? StagedRestore { get; private set; } + /// What the sorting of the folders into homes did when the index opened (owner review 5, #66); null when it had nothing to do. + public HomeLayoutResult? HomeLayout { get; private set; } + + /// Why the folders could not be sorted into homes when the index opened; null when they were, or had nothing to sort. + public Exception? HomeLayoutError { get; private set; } + /// Card detection, eject and format (BRIEF §13); started with the index, replaced by a fake in capture. public IDeviceMonitor Devices { get; set; } = new WindowsDeviceMonitor(); @@ -201,7 +216,8 @@ public sealed class AppServices : IAsyncDisposable new(services.Processing?.Options ?? WorkspaceJobOptions.For(archives).Processing, () => services.Settings.PauseUploadsOnMetered && MeteredNetwork.IsMetered(), services.Workspace.MovedAsync, - () => services.Workspace.Root); + () => services.Workspace.Root, + services.Workspace.SameServer); /// /// Queues a scan of unless one is already waiting or running; the sequences it indexes get @@ -228,6 +244,7 @@ public sealed class AppServices : IAsyncDisposable SaveSettingsAction(); UpdateRenderNode(); ApplyJobSettings(); + if (!Environment.IsCapture) Share.Apply(); } /// Writes the settings file and nothing else: for choices that change only what is shown (the rail, the sequence edited last). @@ -284,6 +301,8 @@ public sealed class AppServices : IAsyncDisposable _schedulerReady.TrySetResult(false); return; } + // Before any job runs: the folders of the workspace and the cache go to their homes (owner review 5, #66). + await SortHomesAsync(Database, ct); try { await StartJobsAsync(Database, startEngine: true, ct); @@ -316,6 +335,8 @@ public sealed class AppServices : IAsyncDisposable { await _stopping.CancelAsync().ConfigureAwait(false); await _schedules.ConfigureAwait(false); + // First: the shared library's clients and its subscriptions to the engine and the scheduler go before they do. + await Share.DisposeAsync().ConfigureAwait(false); _schedulerReady.TrySetResult(false); if (Scheduler is not null) await Scheduler.DisposeAsync().ConfigureAwait(false); _stopping.Dispose(); @@ -348,6 +369,7 @@ public sealed class AppServices : IAsyncDisposable await StartSchedulerAsync(ct).ConfigureAwait(false); if (reopen is null) { + await Share.StartAsync(ct).ConfigureAwait(false); await ScanNowAsync(started, ct).ConfigureAwait(false); return; } @@ -356,6 +378,7 @@ public sealed class AppServices : IAsyncDisposable { if (!string.Equals(reopen, Settings.LastArchivePath, StringComparison.OrdinalIgnoreCase)) return; if (!await ReopenAsync(reopen, ct).ConfigureAwait(false)) continue; + await Share.StartAsync(ct).ConfigureAwait(false); await ScanNowAsync(null, ct).ConfigureAwait(false); Scheduler?.Wake(); return; @@ -474,6 +497,66 @@ public sealed class AppServices : IAsyncDisposable } } + /// + /// Sorts the workspace's projects and the cache's server folders into their homes (owner review 5, #66: + /// ; renames only, a clash to the trash, never deleted), or takes up a sorting a previous + /// start left half done. Projects in use or a workspace being moved wait for a later start; a failure is logged and kept + /// for Settings to tell (), and the start goes on: the folders not sorted read as before. + /// + private async Task SortHomesAsync(ChronosDatabase database, CancellationToken ct) + { + try + { + var migration = new HomeLayoutMigration(new HomeLayoutOptions + { + DataDirectory = Environment.DataDirectory, + WorkspaceRoot = Workspace.IsEnabled ? Workspace.Root : null, + CacheRoot = CacheStore.Folder(Environment, Settings), + Identity = Sync.Identity, + CurrentServer = Sync.LastServer, + Database = database, + }); + var result = await Task.Run(() => migration.ApplyAsync(ct), ct); + if (result != HomeLayoutResult.Nothing) + { + HomeLayout = result; + Log.Info("app", $"Folders sorted into homes: {result.ProjectsMoved} project(s), {result.EntriesMoved} entr(ies), {result.InUse} in use, " + + $"{result.Clashes} clash(es){(result.Deferred is { } deferred ? $", the workspace waits ({deferred})" : string.Empty)}"); + } + } + catch (Exception ex) when (ex is HomeLayoutException or IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException) + { + HomeLayoutError = ex; + Log.Error("app", "The folders could not be sorted into homes; the next start tries again", ex); + } + finally + { + Workspace.Reopen(); + } + } + + /// + /// The scan schedule scanned this PC's archive (any thread): the archives of the servers' downloaded originals are scanned + /// after it (owner review 5, Q1: they are archives of their own, which the schedule, made for one archive, does not name). + /// + private void OnScheduledScanDone(Job job) + { + if (job is not { Kind: JobKind.Scan, State: JobState.Done, ScheduleId: not null, TargetIds: [var scanned] }) return; + _ = Task.Run(async () => + { + try + { + var archives = await Sync.OriginalsArchivesAsync(_stopping.Token).ConfigureAwait(false); + if (archives.Any(a => a.Id == scanned)) return; + foreach (var originals in archives) await QueueScanAsync(originals, full: false, _stopping.Token).ConfigureAwait(false); + } + catch (Exception ex) when (ex is DatabaseException or InvalidOperationException or OperationCanceledException) + { + Log.Warning("app", "The archives of the servers' originals could not be queued to be scanned", ex); + } + }); + } + private async Task StartJobsAsync(ChronosDatabase database, bool startEngine, CancellationToken ct) { _wic = new WicDecoderProvider(); @@ -486,19 +569,24 @@ public sealed class AppServices : IAsyncDisposable MemoryBudget = () => ProcessingTuning.MemoryBudget(Settings, GC.GetGCMemoryInfo().TotalAvailableMemoryBytes), // The housekeeping schedule trims the cache to Settings › Storage › Cache limit (owner review 2, R10). // The workspace-cleanup schedule removes the media past Settings › Workspace's Clean after and Size limit, and reports its trash (phase 5c). + // The shared library's upload-cleanup schedule runs on this PC's scheduler (owner review 5, #67). CleanupSteps = [new CacheTrimStep(() => CacheStore.Folder(Environment, Settings), () => Settings.CacheLimitGb * (1L << 30)), - new WorkspaceCleanStep(() => Workspace), new WorkspaceTrashStep(() => Workspace)], + new WorkspaceCleanStep(() => Workspace), new WorkspaceTrashStep(() => Workspace), new ShareUploadsStep(() => Share)], BackupDirectory = Environment.BackupDirectory, - // Told after each step of a Reorganize, and each sequence a conversion replaced or made, while the rest of the job runs. - SequenceChanged = (id, _, _) => + // While the library is shared, its clients see thumbnails and proxies of what a scan finds, as a server's do. + ImagesAfterScanWhen = () => Share.IsOn, + // Told after each step of a Reorganize, and each sequence a conversion replaced or made, while the rest of the job + // runs; the shared library's clients are told too. + SequenceChanged = (id, change, token) => { SequenceReorganized?.Invoke(id); - return Task.CompletedTask; + return Share.SequenceChangedAsync(id, change, token); }, + ProjectsChanged = (changed, token) => Share.ProjectsChangedAsync(changed, token), }; Archives = new ArchiveService(database, archive); // The videos folder may not lie in the workspace either, and a copy of a server's renders downloads through its connection (phase 5). - Archives.Videos.ProtectedFolders = () => [Workspace.Root]; + Archives.Videos.ProtectedFolders = () => [Workspace.Root, Share.Folder]; Archives.Videos.Servers = Sync; Processing = new ProcessingService(database, ProcessingOptions(archive)); Sync.Open(database, Archives, archive); @@ -508,6 +596,7 @@ public sealed class AppServices : IAsyncDisposable Engine = new JobEngine(database, handlers, new JobEngineOptions { WorkerId = WorkerId, Kinds = kinds, PriorityQueue = () => PriorityQueue }); // The workspace's size limit runs after each copy of media into it (phase 5c). Engine.JobChanged += Workspace.OnJobChanged; + Engine.JobChanged += OnScheduledScanDone; // Sync follows the engine's jobs before it runs any: a render resumed at start that finishes at once is still sent (Export "Sync"). Sync.Update(); // With no handler the engine must not run: an empty kind list would let workers claim (and fail) every job. @@ -528,6 +617,8 @@ public sealed class AppServices : IAsyncDisposable AllowsHardware = presetId => AllowsHardware(Settings.HardwareEncoding, presetId), Host = EncoderHost.Client, ProducedBy = System.Environment.MachineName, + // A render or an advice recorded on this PC reaches the shared library's clients (owner review 5, #67). + SequenceChanged = (id, change, token) => Share.SequenceChangedAsync(id, change, token), Tune = basis => ProcessingTuning.Apply(basis, Settings, GC.GetGCMemoryInfo().TotalAvailableMemoryBytes, System.Environment.ProcessorCount, CacheStore.Folder(Environment, Settings)), }; @@ -554,7 +645,8 @@ public sealed class AppServices : IAsyncDisposable var node = new RenderNodeClient(client, processing.Options, new RenderNodeOptions { ClientName = System.Environment.MachineName, - CacheDirectory = Path.Combine(cache, "render-node"), + // Each server keeps its own downloads (owner review 5, #66: the render-node folder of its home in the cache). + CacheDirectory = Path.Combine(CacheStore.ServerFolder(cache, Sync.KeyOf(session.Address), Sync.Identity), HomeFolders.RenderNode), CacheLimitBytes = Settings.CacheLimitGb * (1L << 30), }); node.Start(); diff --git a/src/Chronos.App/Infrastructure/AppSettings.cs b/src/Chronos.App/Infrastructure/AppSettings.cs index f8abdfe0..b4a56044 100644 --- a/src/Chronos.App/Infrastructure/AppSettings.cs +++ b/src/Chronos.App/Infrastructure/AppSettings.cs @@ -10,6 +10,7 @@ using Chronos.Core.Naming; using Chronos.Core.Project; using Chronos.Data.Archiving; using Chronos.Data.Repositories; +using Chronos.Data.Sync; using Chronos.Ui.Theming; namespace Chronos.App.Infrastructure; @@ -66,6 +67,61 @@ public sealed class TrustedCertificate public DateTimeOffset TrustedAt { get; set; } } +/// +/// A server this PC signed in to that announced its stable id (owner review 5, #66): its name and last address, the TLS +/// fingerprint it presented, the address keys it was reached under before (or besides) its id +/// (: projects, links and jobs made then still name them), the archive its +/// downloaded originals go to, and when it was last seen. Its folders (servers\<id> in the workspace and the +/// cache) are named by the id, never by the name. +/// +public sealed class KnownServer +{ + public Guid Id { get; set; } + public string? Name { get; set; } + public string? LastAddress { get; set; } + public string? Fingerprint { get; set; } + public List Aliases { get; set; } = []; + + /// The archive of this PC that holds the server's downloaded originals (owner review 5, Q1); null until the first download. + public Guid? OriginalsArchiveId { get; set; } + + public DateTimeOffset LastSeen { get; set; } +} + +/// +/// Settings › Server › Sharing (owner review 5, #67): this PC's library served to the LAN by the server Chronos hosts +/// while it runs. Absent in a 1.0 settings file: off, on Docker's ports. +/// +public sealed class ShareSettings +{ + public const int DefaultHttpsPort = 8443; + public const int DefaultHttpPort = 8080; + + public bool Enabled { get; set; } + + /// The name clients see; empty: this PC's name. + public string? Name { get; set; } + + public int HttpsPort { get; set; } = DefaultHttpsPort; + public int HttpPort { get; set; } = DefaultHttpPort; + + /// The ports clients reach when a router forwards others to this PC; null: the ones above. + public int? PublicHttpsPort { get; set; } + + public int? PublicHttpPort { get; set; } + + /// Announce the library to Chronos programs on the local network. + public bool Discovery { get; set; } = true; + + /// What restarts a running share when it changes (the name, the ports, the discovery); the rest applies live. + public bool SameEndpoint(ShareSettings other) + { + ArgumentNullException.ThrowIfNull(other); + return string.Equals(Name?.Trim() ?? string.Empty, other.Name?.Trim() ?? string.Empty, StringComparison.Ordinal) && HttpsPort == other.HttpsPort && + HttpPort == other.HttpPort && PublicHttpsPort == other.PublicHttpsPort && PublicHttpPort == other.PublicHttpPort && Discovery == other.Discovery; + } +} + /// /// Per-user preferences (language, theme, window layout, archive defaults, server session). Kept in /// settings.json next to the database and written atomically, because language and theme apply before the @@ -257,6 +313,22 @@ public sealed class AppSettings public List TrustedCertificates { get; set; } = []; public List RecentServers { get; set; } = []; + /// + /// The servers known by their stable id and the address keys each was reached under (owner review 5, #66): a server's + /// projects, links and jobs stay its own whatever address it is reached by. This PC's state: Reset and Import keep it, + /// Export leaves it out. + /// + public List KnownServers { get; set; } = []; + + /// The alias table of , as the sync and the workspace compare server keys through it. + public ServerIdentity KnownIdentity() => new([.. KnownServers.Where(k => k.Id != Guid.Empty).Select(k => new KnownServerKey(k.Id, [.. k.Aliases]))]); + + /// The known server of ; null when this PC has none. + public KnownServer? FindKnownServer(Guid id) => KnownServers.FirstOrDefault(k => k.Id == id); + + /// Settings › Server › Sharing: this PC's library shared to the LAN while Chronos runs (owner review 5, #67). + public ShareSettings Share { get; set; } = new(); + /// Let the server send render jobs to this PC (BRIEF §14.7). public bool RenderNodeOptIn { get; set; } @@ -377,6 +449,7 @@ public sealed class AppSettings ProtectedToken = ProtectedToken, TrustedCertificates = TrustedCertificates, RecentServers = RecentServers, + KnownServers = KnownServers, Window = Window, RailCollapsed = RailCollapsed, EditorGroups = EditorGroups, @@ -400,6 +473,7 @@ public sealed class AppSettings copy.WorkspaceFolder = null; copy.WorkspaceRecent = []; copy.WorkspaceOpened = []; + copy.KnownServers = []; return copy; } @@ -423,6 +497,7 @@ public sealed class AppSettings imported.WorkspaceFolder = WorkspaceFolder; imported.WorkspaceRecent = WorkspaceRecent; imported.WorkspaceOpened = WorkspaceOpened; + imported.KnownServers = KnownServers; return imported; } } diff --git a/src/Chronos.App/Infrastructure/DiagnosticsBundle.cs b/src/Chronos.App/Infrastructure/DiagnosticsBundle.cs index 35c54b61..ad08192c 100644 --- a/src/Chronos.App/Infrastructure/DiagnosticsBundle.cs +++ b/src/Chronos.App/Infrastructure/DiagnosticsBundle.cs @@ -5,10 +5,12 @@ using System.Text; using Chronos.App.Settings; using Chronos.Core.Diagnostics; using Chronos.Core.Export; +using Chronos.Core.IO; using Chronos.Core.Model; using Chronos.Core.Windows.Codecs; using Chronos.Data; using Chronos.Data.Sqlite; +using Chronos.Data.Sync; namespace Chronos.App.Infrastructure; @@ -34,8 +36,11 @@ public static class DiagnosticsBundle var settings = services.Settings.ToJson(); var tailBytes = AppLogging.DiagnosticsTailBytes(services.Settings); var report = Report(services.Environment, extraLines) + DatabaseLine(services.Database); + var workspace = services.Workspace; + var cache = CacheStore.Folder(services.Environment, services.Settings); return Task.Run(async () => { + report += HomesLines(workspace, cache); var failures = services.Database is { } db ? (await db.Jobs.ListAsync(JobState.Failed, FailedJobs, null, ct).ConfigureAwait(false)).Items : []; var codecs = Codecs(services.Encoders); var path = ExportNaming.Unique(folder, $"Chronos diagnostics {DateTime.Now.ToString("yyyy-MM-dd HHmm", CultureInfo.InvariantCulture)}", ".zip"); @@ -76,6 +81,33 @@ public static class DiagnosticsBundle return sb.ToString(); } + /// The homes' folders (owner review 5, #66): the workspace's, each with its projects, and the servers' in the cache. + private static string HomesLines(Chronos.App.Workspace.WorkspaceHost workspace, string cache) + { + var sb = new StringBuilder(); + try + { + if (workspace.IsEnabled && Directory.Exists(workspace.Root)) + { + var homes = workspace.Homes; + sb.AppendLine(CultureInfo.InvariantCulture, $"Workspace {homes.Root} ({(homes.IsSplit ? "homes" : "1.0 layout")})"); + foreach (var home in homes.Homes()) + sb.AppendLine(CultureInfo.InvariantCulture, $" {(home.IsLegacy ? "(parent)" : home.Folder)}: {home.Store.List().Count} project(s){(home.Server?.Name is { } name ? " · " + name : string.Empty)}"); + } + var servers = CacheStore.ServersFolder(cache); + if (Directory.Exists(servers)) + { + foreach (var folder in Directory.EnumerateDirectories(servers).Order(StringComparer.Ordinal)) + sb.AppendLine(CultureInfo.InvariantCulture, $"Cache home {Path.GetFileName(folder)}"); + } + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException) + { + sb.AppendLine("The homes could not be listed: " + ex.Message); + } + return sb.ToString(); + } + private static string DatabaseLine(ChronosDatabase? database) { if (database is null) return "Index not open\n"; @@ -135,6 +167,19 @@ public static class CacheStore public static string Folder(AppEnvironment environment, AppSettings settings) => string.IsNullOrWhiteSpace(settings.CacheFolder) ? environment.CacheDirectory : settings.CacheFolder!; + /// The servers' homes in the cache (<cache>\servers, owner review 5, #66). + public static string ServersFolder(string cache) => Path.Combine(cache, HomeFolders.Servers); + + /// + /// The home of server in the cache (<cache>\servers\<folder>, named by its + /// canonical key through ): its proxies, render-node downloads and staged imports. + /// + public static string ServerFolder(string cache, string serverKey, ServerIdentity identity) + { + ArgumentNullException.ThrowIfNull(identity); + return Path.Combine(ServersFolder(cache), identity.FolderName(serverKey)); + } + /// Creates the folder (if needed) and marks it as Chronos's. public static void Prepare(string folder) { diff --git a/src/Chronos.App/Jobs/DesktopScheduleHost.cs b/src/Chronos.App/Jobs/DesktopScheduleHost.cs index cf29b2f5..25f622f8 100644 --- a/src/Chronos.App/Jobs/DesktopScheduleHost.cs +++ b/src/Chronos.App/Jobs/DesktopScheduleHost.cs @@ -67,6 +67,8 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func CleanupSteps => archives()?.CleanupSteps.Select(s => s.Name).ToList() ?? []; @@ -84,7 +86,11 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func GetArchiveAsync(CancellationToken cancellationToken) { if (database() is not { } db || archives() is not { } service) return null; - var archive = CurrentArchive.Pick(await db.Archives.ListAsync(cancellationToken).ConfigureAwait(false), settings.LastArchivePath); + var listed = await db.Archives.ListAsync(cancellationToken).ConfigureAwait(false); + // Never a server's originals archive in place of this PC's (owner review 5): the app scans those after this one. + var originals = settings.KnownServers.Select(k => k.OriginalsArchiveId).OfType().ToHashSet(); + var archive = (settings.LastArchivePath is { Length: > 0 } last ? CurrentArchive.At(listed, last) : null) + ?? CurrentArchive.Pick([.. listed.Where(a => !originals.Contains(a.Id))], null) ?? CurrentArchive.Pick(listed, null); if (archive is null || ArchiveService.GetAvailability(archive) == ArchiveAvailability.Offline) return null; try { @@ -110,14 +116,15 @@ public sealed class DesktopScheduleHost(AppSettings settings, Funccache-trim (owner review 2, R10): brings the cache folder down to Settings › Storage › /// Cache limit, oldest files first, skipping files in use (). The proxies of server sequences /// (complete sets the sync keeps), the render node's folder (it trims its own downloads to the same limit) and the copies an -/// import to the server stages are never trimmed; Settings › Storage › Clear still empties everything. +/// import to the server stages are never trimmed, in the former shared folders and in each server's own (servers, +/// owner review 5); Settings › Storage › Clear still empties everything. /// public sealed class CacheTrimStep(Func folder, Func limitBytes) : ICleanupStep { public const string StepName = "cache-trim"; /// Folders of the cache the trim leaves whole. - public static IReadOnlyList Kept { get; } = ["proxies", "render-node", "server-import"]; + public static IReadOnlyList Kept { get; } = ["proxies", "render-node", "server-import", Chronos.Core.IO.HomeFolders.Servers]; public string Name => StepName; diff --git a/src/Chronos.App/Library/LibraryActions.cs b/src/Chronos.App/Library/LibraryActions.cs index 6f99ff4d..a13f8711 100644 --- a/src/Chronos.App/Library/LibraryActions.cs +++ b/src/Chronos.App/Library/LibraryActions.cs @@ -117,11 +117,7 @@ public sealed class LibraryActions(ShellViewModel shell) await remote.Service.EnqueueSendExportsAsync(engine, remote.Server, selected.Sequence); return true; case SyncAction.DownloadOriginals when entry is not null: - if ((entry.Local?.ArchiveId ?? (await Services.Sync.CurrentArchiveAsync())?.Id) is not { } archive) - { - shell.Notify(Loc.L("Errors.Sync.NoArchive")); - return false; - } + if (await Services.Sync.OriginalsForDownloadAsync(entry.Local, (title, message, isError) => shell.Notify(title, message, isError: isError)) is not { } archive) return false; await remote.Service.EnqueueDownloadAsync(engine, remote.Server, entry.Id, entry.Title, SyncDownloadMode.Originals, archive); return true; case SyncAction.GetExports when entry is not null: diff --git a/src/Chronos.App/Sections/ImportViewModel.cs b/src/Chronos.App/Sections/ImportViewModel.cs index acd4a894..fc17cc81 100644 --- a/src/Chronos.App/Sections/ImportViewModel.cs +++ b/src/Chronos.App/Sections/ImportViewModel.cs @@ -989,7 +989,20 @@ public sealed class ImportViewModel : SectionViewModel /// What the signed-in user may still store on the server; null without a quota. private long? ServerSpace() => Services.Server.User is { QuotaBytes: > 0 } user ? System.Math.Max(0, user.QuotaBytes - user.UsedBytes) : null; - private string ServerStagingRoot => Path.Combine(CacheStore.Folder(Services.Environment, Services.Settings), "server-import"); + /// + /// Where an import to the server is staged before it is uploaded: the signed-in server's own folder of the cache + /// (servers\<id>\import, owner review 5); signed out, the cache's former shared folder. + /// + private string ServerStagingRoot + { + get + { + var cache = CacheStore.Folder(Services.Environment, Services.Settings); + return Services.Sync.Server is { } server + ? Path.Combine(CacheStore.ServerFolder(cache, server, Services.Sync.Identity), Chronos.Core.IO.HomeFolders.Import) + : Path.Combine(cache, Chronos.Data.Homes.HomeLayoutMigration.LegacyServerImport); + } + } private async Task PlanAsync() { diff --git a/src/Chronos.App/Sections/SequencePickerViewModel.cs b/src/Chronos.App/Sections/SequencePickerViewModel.cs index 8cb7db73..21fef618 100644 --- a/src/Chronos.App/Sections/SequencePickerViewModel.cs +++ b/src/Chronos.App/Sections/SequencePickerViewModel.cs @@ -189,7 +189,7 @@ public sealed class SequencePickerViewModel : LocalizedViewModel { var generation = _generation; foreach (var item in WorkspaceItems.Where(i => change.ProjectId is { } id ? i.ProjectId == id - : i.Entry.IsServerHome && string.Equals(i.Entry.Home.Server, change.Server, StringComparison.OrdinalIgnoreCase)).ToList()) + : i.Entry.IsServerHome && Shell.Services.Workspace.SameServer(i.Entry.Home.Server, change.Server)).ToList()) { if (generation != _generation) return; try diff --git a/src/Chronos.App/Sections/SequenceViewModel.cs b/src/Chronos.App/Sections/SequenceViewModel.cs index c6e7a8fb..e9987ec0 100644 --- a/src/Chronos.App/Sections/SequenceViewModel.cs +++ b/src/Chronos.App/Sections/SequenceViewModel.cs @@ -643,7 +643,7 @@ public sealed class SequenceViewModel : SectionViewModel { workspace.Remember(row.Id, entry.ProjectId); workspace.RecordOpened(entry.ProjectId); - return (new WorkspaceSequenceSource(workspace.Sync, entry.ProjectId, db, decoder, services.Engine), row.DisplayTitle); + return (new WorkspaceSequenceSource(workspace.SyncOf(entry.ProjectId), entry.ProjectId, db, decoder, services.Engine), row.DisplayTitle); } var projectId = entry?.ProjectId ?? request?.ProjectId; string? newName = null; @@ -748,9 +748,9 @@ public sealed class SequenceViewModel : SectionViewModel // Its analyses and renders travel on a connection of the signed-in session, when that is the project's server: // made again whenever the sign-in changes, so a project opened signed out renders once signed in. var server = entry.Home.Server; - var editorHome = new WorkspaceServerHome(() => string.Equals(sync.Server, server, StringComparison.OrdinalIgnoreCase) ? sync.ConnectEditor() : null, + var editorHome = new WorkspaceServerHome(() => sync.Identity.Same(sync.Server, server) ? sync.ConnectEditor() : null, () => sync.Session); - return new ServerOpen((new WorkspaceSequenceSource(workspace.Sync, entry.ProjectId, db, decoder, services.Engine, editorHome), entry.SequenceTitle)); + return new ServerOpen((new WorkspaceSequenceSource(workspace.SyncOf(entry.ProjectId), entry.ProjectId, db, decoder, services.Engine, editorHome), entry.SequenceTitle)); } // An account that may not edit checks nothing out: it is shown with proxies, read-only, as on an older server. if (!sync.Policy.CanEdit || sync.ServerHome(remoteId) is not { } home) return null; diff --git a/src/Chronos.App/Sections/ServerView.xaml b/src/Chronos.App/Sections/ServerView.xaml index 2f8b9af0..dc43e909 100644 --- a/src/Chronos.App/Sections/ServerView.xaml +++ b/src/Chronos.App/Sections/ServerView.xaml @@ -5,7 +5,8 @@ xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui" xmlns:infra="clr-namespace:Chronos.App.Infrastructure" xmlns:shell="clr-namespace:Chronos.App.Shell" - xmlns:srv="clr-namespace:Chronos.App.Server"> + xmlns:srv="clr-namespace:Chronos.App.Server" + xmlns:sec="clr-namespace:Chronos.App.Sections"> - + + - + + + + + +