E2: correzioni della revisione delle copie esterne
verifica / controlli (push) Canceled after 0s
verifica / prove (push) Canceled after 0s
verifica / installatore (push) Canceled after 0s
verifica / immagine (push) Canceled after 0s

- Nome libero scelto prima di scrivere, libero sul disco e nel database;
  una riga orfana sul nome diventa «Tolto» (guardando il suo percorso,
  anche se differisce solo per le maiuscole): prima la copia finiva
  «Non riuscito» con il file già scritto, o toglieva la copia buona.
- «Controlla le copie» rilegge la radice e riguarda i file mancanti;
  con il disco staccato si ferma e mette in pausa senza segnare nulla.
- Su Linux lo spostamento sul nome finale non sostituisce mai un file
  (renameat2 RENAME_NOREPLACE, poi link e unlink).
- Le copie in coda di un lavoro interrotto diventano «Interrotta» e si
  riprendono; il permesso dei lavori lunghi si tiene già nel piano.
- «Superato» con il file di nuovo in libreria: filtro, piano e «Copia di
  nuovo» d'accordo; l'adozione ravviva la riga invece di fallire.
- «Una copia sola» con una regola sola in filtro, piano, visualizzatore
  e copiatore (solo copie di un altro account in cartelle in uso).
- Controllo della cartella per identità vera (percorso finale, realpath,
  dispositivo di mountinfo): riconosce collegamenti e bind mount di una
  sottocartella della libreria.
- Sfoglia delle cartelle con tempi massimi; «Nessuna cartella» solo se
  non ce n'è; «In copia…» nel visualizzatore; numero e fuoco stabili in
  «Copia di nuovo anche…»; una sola lettura per volta nella Dashboard.
- Prove dell'interfaccia indipendenti dall'ora e dal file scelto; prove
  nuove in ExportReviewTests, ExportFolderCheckTests, ExportRootTests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-27 17:02:06 +01:00
1 parent 28c7f814b1
commit 36ad5c6f9d
28 files changed
+1314 -112

No files matched your search

@@ -33,6 +33,9 @@ export async function mountExport(page) {
let timer = 0;
let ticks = 0;
let stopped = false;
// One reading at a time: a command or a change during a reading asks for one more right after it, never a second chain.
let inFlight = false;
let rerun = false;
page.onLeave(() => {
stopped = true;
clearTimeout(timer);
@@ -53,6 +56,29 @@ export async function mountExport(page) {
async function poll() {
if (stopped) return;
if (inFlight) {
rerun = true;
return;
}
inFlight = true;
clearTimeout(timer);
try {
await read();
} finally {
inFlight = false;
}
if (stopped) return;
clearTimeout(timer);
if (rerun) {
rerun = false;
wasRunning = null;
poll();
return;
}
timer = setTimeout(poll, progress && progress.running ? 1000 : 5000);
}
async function read() {
try {
progress = await api('/api/export/progress', { signal: page.signal });
} catch (error) {
@@ -65,8 +91,6 @@ export async function mountExport(page) {
// The jobs and the folders follow the copy: when it starts or ends, and every few seconds while it works.
if (running !== wasRunning || !running || ticks % 5 === 0) await loadSide();
wasRunning = running;
if (stopped) return;
timer = setTimeout(poll, running ? 1000 : 5000);
}
/** Asks again now (after a command), keeping one timer. */
@@ -165,7 +165,10 @@ export async function destinationDialog({ scope, accountId = null, username = ''
}
}
async function browse(path) {
// focusPath: the folder whose button had the keyboard; after the list is drawn again the focus goes back there
// (or to the first folder), never lost on the page behind the dialog.
async function browse(path, focusPath = null) {
const hadFocus = folderPart.contains(document.activeElement);
try {
const list = await api(`/api/export/folders${path ? `?path=${encodeURIComponent(path)}` : ''}`);
fill(folderPart, h('div.pannello.sfoglia',
@@ -173,10 +176,16 @@ export async function destinationDialog({ scope, accountId = null, username = ''
list.parent != null ? h('button.btn.nudo.piccolo.destra', { type: 'button', onclick: () => browse(list.parent || null) }, icon('arrow-left', 's'), t('esportazione.dialogo.su')) : null),
list.folders.length
? h('ul.sfoglia-elenco', list.folders.map((f) => h(`li${f.path === state.path ? '.scelta' : ''}`,
h('button.sfoglia-voce', { type: 'button', 'aria-pressed': String(f.path === state.path), onclick: () => { state.path = f.path; checkFolder(f.path); browse(list.relative || null); } },
h('button.sfoglia-voce', { type: 'button', dataset: { path: f.path }, 'aria-pressed': String(f.path === state.path), onclick: () => { state.path = f.path; checkFolder(f.path); browse(list.relative || null, f.path); } },
icon(f.path === state.path ? 'circle-check' : 'folder', 's'), h('span', f.name)),
f.hasSubfolders ? h('button.btn.nudo.solo', { type: 'button', 'aria-label': t('esportazione.dialogo.apri', { nome: f.name }), onclick: () => browse(f.path) }, icon('chevron-right', 's')) : null)))
: h('p.vuoto-elenco', t('esportazione.dialogo.vuota'))));
if (hadFocus) {
const items = [...folderPart.querySelectorAll('.sfoglia-voce')];
const target = items.find((b) => focusPath != null && b.dataset.path === focusPath) || items[0]
|| folderPart.querySelector('button');
if (target) target.focus();
}
} catch (error) {
fill(folderPart, h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', error.message)));
}
@@ -409,6 +418,10 @@ export function copyDialog(selection, { title } = {}) {
let plan = null;
let token = 0;
let busy = false;
// The files «tolti o superati» as the plan without «Copia di nuovo» counts them: the choice keeps its label and
// stays on screen whatever the plan with it says (with it they are files to copy).
let againCount = 0;
let refocusAgain = false;
async function load() {
const mine = ++token;
@@ -417,6 +430,7 @@ export function copyDialog(selection, { title } = {}) {
const result = await api('/api/export/plan', { method: 'POST', body: { ...selection, copyAgain } });
if (mine !== token) return;
plan = result;
if (!copyAgain) againCount = result.removedOrSuperseded || 0;
draw();
} catch (error) {
if (mine !== token) return;
@@ -446,16 +460,26 @@ export function copyDialog(selection, { title } = {}) {
d.problem || d.paused ? h('div.avviso.ambra', icon('pause', 's'), h('span', t('esportazione.copia.inAttesa', { problema: d.problem || t('esportazione.inPausa') }))) : null)));
let empty = null;
if (!p.files) {
empty = p.destinations.length === 0 && p.notExported && !p.alreadyCopied && !p.removedOrSuperseded
? h('p.aiuto', t('esportazione.copia.nessunaCartella'))
: h('p.aiuto', t('esportazione.copia.niente'));
// «Nessuna cartella» only when there is really none; files of accounts not exported (or of kinds the folder
// does not copy) have their own words.
let key = 'esportazione.copia.niente';
if (p.hasDestination === false) key = 'esportazione.copia.nessunaCartella';
else if (p.notExported && !p.alreadyCopied && !p.removedOrSuperseded) key = 'esportazione.copia.nienteNonEsportati';
empty = h('p.aiuto', t(key));
}
const again = p.removedOrSuperseded
? h('div.di-nuovo',
checkbox({ checked: copyAgain, label: t('esportazione.copia.diNuovo', { n: p.removedOrSuperseded }), onchange: (v) => { copyAgain = v; load(); } }),
h('p.aiuto', t('esportazione.copia.diNuovoAiuto')))
const choice = againCount || copyAgain
? checkbox({
checked: copyAgain,
label: t('esportazione.copia.diNuovo', { n: againCount || p.removedOrSuperseded }),
onchange: (v) => { copyAgain = v; refocusAgain = true; load(); },
})
: null;
const again = choice
? h('div.di-nuovo', choice, h('p.aiuto', t('esportazione.copia.diNuovoAiuto')))
: null;
fill(content, summary, rows.length ? h('ul.destinazioni-copia.pannello', rows) : null, empty, again);
if (refocusAgain && choice) choice.input.focus();
refocusAgain = false;
fill(start, icon('copy'), t('esportazione.copia.pulsante', { n: p.files }));
start.disabled = busy || !p.files;
}
+27 -4
View File
@@ -5,7 +5,8 @@
import { api, withCarried } from '../core/api.js';
import { caps, serverNow } from '../core/context.js';
import { h, icon, fill } from '../core/dom.js';
import { h, icon, fill, later } from '../core/dom.js';
import { onLibrary } from '../core/engine.js';
import { t, dayName, capitalize, bytes, duration, number, ago, shortDay } from '../core/text.js';
import { avatar, label, showError, toast } from '../core/ui.js';
import { confirmDelete } from './library.js';
@@ -26,6 +27,8 @@ export function openViewer({ tile, source, origin, onDeleted }) {
let fileIndex = 0;
let zoomed = false;
let token = 0;
// The copies whose «Copia di nuovo» started a job: their button stays «In copia…» until the job ends (spec §4.10).
const copying = new Set();
const where = h('span.dove');
const closeButton = h('button.tondino', { type: 'button', 'aria-label': t('vis.chiudi'), title: t('vis.chiudi'), onclick: close }, icon('x'));
@@ -77,6 +80,8 @@ export function openViewer({ tile, source, origin, onDeleted }) {
function close() {
document.removeEventListener('keydown', onKey, true);
stopWatching();
onCopiesChanged.cancel();
for (const v of box.querySelectorAll('video')) v.pause();
if (document.fullscreenElement) document.exitFullscreen().catch(() => {});
box.remove();
@@ -286,17 +291,24 @@ export function openViewer({ tile, source, origin, onDeleted }) {
const vars = { cartella: copy.destination, giorno: shortDay(copy.at.day, today), nome: copy.forAccount || '' };
const key = { copied: copy.forAccount ? 'copiatoPer' : 'copiato', removed: 'tolto', superseded: 'superato' }[copy.state] || 'fallito';
const text = t(`esportazione.vis.${key}`, vars) + (copy.destinationRetired ? ` (${t('esportazione.vis.tolta')})` : '');
const busy = copying.has(copy.copyId);
const again = copy.canCopyAgain
? h('button.btn.nudo.piccolo.copia-di-nuovo', {
type: 'button',
disabled: busy,
onclick: async (e) => {
const button = e.currentTarget;
button.disabled = true;
const job = await copyAgain(copy.copyId);
if (job) await load(entry.id, fileIndex, media.id);
else button.disabled = false;
if (!job) {
button.disabled = false;
return;
}
// The job runs on: the row says so, and the viewer reads the copies again when it ends (onLibrary «export»).
copying.add(copy.copyId);
await load(entry.id, fileIndex, media.id);
},
}, icon('rotate-cw', 's'), t('esportazione.vis.diNuovo'))
}, icon('rotate-cw', 's'), t(busy ? 'esportazione.vis.inCopia' : 'esportazione.vis.diNuovo'))
: null;
return [h('dt', t('esportazione.vis.copia')), h('dd.riga-copia', h('span', text), again)];
}
@@ -331,6 +343,17 @@ export function openViewer({ tile, source, origin, onDeleted }) {
else close();
}
// A job of the copies ended (or a folder changed): the rows of «Copia» are read again, on the same file.
const onCopiesChanged = later(() => {
if (!entry) return;
copying.clear();
const current = entry.media[fileIndex];
load(entry.id, fileIndex, current ? current.id : null);
}, 400);
const stopWatching = onLibrary((change) => {
if (change.reason === 'export') onCopiesChanged();
});
document.addEventListener('keydown', onKey, true);
document.body.append(box);
closeButton.focus();
+2
View File
@@ -1183,6 +1183,7 @@
"diNuovoAiuto": "Scrive un file nuovo; la copia di prima resta dov'è.",
"niente": "Niente da copiare: i file scelti sono già copiati, non si esportano o non sono in libreria.",
"nessunaCartella": "Nessuna cartella delle copie: scegline una in Impostazioni → Esportazione.",
"nienteNonEsportati": "Niente da copiare: questi file sono di account che non si esportano o di tipi che la cartella non copia.",
"pulsante": "Copia 1 file|Copia {n} file",
"vediAvanzamento": "Apri l'esportazione"
},
@@ -1206,6 +1207,7 @@
"fallito": "Non riuscito in {cartella} il {giorno}",
"tolta": "cartella tolta",
"diNuovo": "Copia di nuovo",
"inCopia": "In copia…",
"copiaIn": "Copia in…"
},
"account": {