Keep oldest snapshot so playing the ledger is possible from local data. (#10814)

This commit is contained in:
sakridge 2020-06-25 20:41:44 -07:00 committed by GitHub
parent 0fde0d7379
commit 7430978d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -293,8 +293,10 @@ pub fn archive_snapshot_package(snapshot_package: &AccountsPackage) -> Result<()
let metadata = fs::metadata(&archive_path)?;
fs::rename(&archive_path, &snapshot_package.tar_output_file)?;
// Keep around at most two snapshot archives
let archives = get_snapshot_archives(snapshot_package.tar_output_file.parent().unwrap());
// Keep around at most three snapshot archives
let mut archives = get_snapshot_archives(snapshot_package.tar_output_file.parent().unwrap());
// Keep the oldest snapshot so we can always play the ledger from it.
archives.pop();
for old_archive in archives.into_iter().skip(2) {
fs::remove_file(old_archive.0)
.unwrap_or_else(|err| info!("Failed to remove old snapshot: {:}", err));