fix(sync): S-05 — delete and shred all chunks when truncating to 0 bytes

This commit is contained in:
2026-09-19 08:59:00 +02:00
parent f557a9ddfa
commit 9634beb744
3 changed files with 147 additions and 1 deletions
+6 -1
View File
@@ -335,7 +335,12 @@ pub fn sync_single_file_to_vault(
}
// Bei Überschreiben einer ehemals größeren Datei überzählige alte Chunks entfernen
db.truncate_chunks_after(node_id, chunk_idx.saturating_sub(1))?;
if bytes_written == 0 {
// S-05: 0-Byte Datei: Alle Chunks (inkl. Chunk 0) restlos löschen und shreddern
db.delete_all_chunks(node_id)?;
} else {
db.truncate_chunks_after(node_id, chunk_idx.saturating_sub(1))?;
}
// S-04: Verwende bytes_written statt local_size zur Vermeidung von TOCTOU-Diskrepanzen
db.update_node_size_and_time(node_id, bytes_written, local_mtime)?;