fix: confine every reconstitute target to the exports directory and never overwrite an existing file

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 21:11:34 +07:00
parent c18815eb5d
commit edc74d79c0
5 changed files with 44 additions and 12 deletions

View File

@@ -172,7 +172,7 @@ impl Offsite {
)?;
let size = file.as_file().metadata()?.len();
file.as_file().sync_all()?;
file.persist(dest)?;
file.persist_noclobber(dest)?;
Ok(size)
}

View File

@@ -655,7 +655,8 @@ impl Vault {
}
let len = temp.as_file().metadata()?.len();
temp.as_file().sync_all()?;
temp.persist(dest)?;
// never replace a file that is already there
temp.persist_noclobber(dest)?;
Ok(len)
}