From 7430978d1a32f6242462018afcdb2add80197779 Mon Sep 17 00:00:00 2001 From: sakridge Date: Thu, 25 Jun 2020 20:41:44 -0700 Subject: [PATCH] Keep oldest snapshot so playing the ledger is possible from local data. (#10814) --- runtime/src/snapshot_utils.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index e14721c663..e40e4a9f72 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -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));