Cleanup impl for remove_tmp_snapshot_archives() (#32297)

This commit is contained in:
Brooks 2023-06-27 15:51:28 -04:00 committed by GitHub
parent 8ddce4b566
commit 9fb105c801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -623,11 +623,12 @@ fn is_bank_snapshot_complete(bank_snapshot_dir: impl AsRef<Path>) -> bool {
pub fn remove_tmp_snapshot_archives(snapshot_archives_dir: impl AsRef<Path>) { pub fn remove_tmp_snapshot_archives(snapshot_archives_dir: impl AsRef<Path>) {
if let Ok(entries) = std::fs::read_dir(snapshot_archives_dir) { if let Ok(entries) = std::fs::read_dir(snapshot_archives_dir) {
for entry in entries.flatten() { for entry in entries.flatten() {
let file_name = entry if entry
.file_name() .file_name()
.into_string() .to_str()
.unwrap_or_else(|_| String::new()); .map(|file_name| file_name.starts_with(TMP_SNAPSHOT_ARCHIVE_PREFIX))
if file_name.starts_with(TMP_SNAPSHOT_ARCHIVE_PREFIX) { .unwrap_or(false)
{
let path = entry.path(); let path = entry.path();
let result = if path.is_dir() { let result = if path.is_dir() {
fs_err::remove_dir_all(path) fs_err::remove_dir_all(path)