review 06/07/08: loeschen in papierkorb, backup-erfolg ehrlich, verschieben sicher
08 Loeschen: statt fs.rmSync (endgueltig) jetzt in den Windows-Papierkorb (wiederherstellbar, Pfad per env an PowerShell -> keine Shell-Injektion); schlaegt es fehl, bleibt das Projekt. _Tools-Schutz case-insensitiv. Dialog nennt Papierkorb + letzten Backup-Stand. 06 Backup: Kopier-Entscheidung + Erfolg am Robocopy-Exitcode statt nur an geparsten Konsolenzeilen; bei unklarem Ergebnis kein gruener Stand, sondern 'Ergebnis unklar' + sicherheitshalber kopieren. README: Wiederherstellung, Ueberschreiben desselben Ziels, Papierkorb. 07 Verschieben: Original erst nach verifizierter, nicht-leerer Uebernahme entfernen; Entfernen-Fehler laesst beide Staende nutzbar. Case-only-Umbenennen rollt bei Fehler im zweiten Schritt zurueck bzw. meldet den Zwischenpfad. Getestet: Papierkorb-Loeschung eines Wegwerf-Ordners -> landet wiederherstellbar im Papierkorb. node --check alle Dateien, i18n-Paritaet 801/801. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -213,6 +213,7 @@ function check(scope = null, autoCopy = false, targetId = null, opts = {}) {
|
||||
if (!fs.existsSync(cfg.t.path) && !fs.existsSync(share)) throw new Error(`Backup-Ziel „${cfg.t.name}“ nicht erreichbar: ${cfg.t.path} – Laufwerk/NAS angeschlossen und eingeschaltet?`)
|
||||
const newF = { n: 0, b: 0 }, changed = { n: 0, b: 0 }, extra = { n: 0, b: 0 }
|
||||
const perProject = new Map()
|
||||
let pendingByRc = false // robocopy's own exit code says files still need copying (bit 1)
|
||||
for (const it of items) {
|
||||
if (!fs.existsSync(it.source)) throw new Error(`Projektordner fehlt: ${it.source}`)
|
||||
fs.mkdirSync(it.target, { recursive: true })
|
||||
@@ -236,6 +237,7 @@ function check(scope = null, autoCopy = false, targetId = null, opts = {}) {
|
||||
})
|
||||
if (state.phase === 'cancelled') return
|
||||
if (rc >= 8) throw new Error(`Prüfung fehlgeschlagen (robocopy ${rc})`)
|
||||
if (rc >= 0 && (rc & 1)) pendingByRc = true // robocopy found files to copy, even if parsing missed them
|
||||
}
|
||||
state.check = {
|
||||
at: new Date().toISOString(), scope: state.scope,
|
||||
@@ -245,10 +247,13 @@ function check(scope = null, autoCopy = false, targetId = null, opts = {}) {
|
||||
extraFiles: extra.n, extraBytes: extra.b,
|
||||
projects: [...perProject.values()].sort((a, b) => b.bytes - a.bytes),
|
||||
}
|
||||
state.check.pendingByRc = pendingByRc
|
||||
state.phase = 'ready'
|
||||
if (autoCopy) {
|
||||
if (state.check.files) startCopy()
|
||||
else { for (const it of items) record(cfg.t, it.root, scope?.folder, 0, 0, 0, null); state.phase = 'done' } // already complete
|
||||
// copy whenever the parser OR robocopy's exit code says something is pending;
|
||||
// only record a green "already complete" when both agree there is nothing to copy
|
||||
if (state.check.files || pendingByRc) startCopy()
|
||||
else { for (const it of items) record(cfg.t, it.root, scope?.folder, 0, 0, 0, null); state.phase = 'done' }
|
||||
}
|
||||
})
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user