Skip to content

Commit

Permalink
remove file every after use (#515)
Browse files Browse the repository at this point in the history
CI test will be confirmed on #513
  • Loading branch information
b-yap authored Apr 29, 2024
1 parent b1dc81f commit 9aafee4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions clients/vault/src/oracle/collector/proof_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ impl ScpMessageCollector {
"get_envelopes_from_horizon_archive(): The contained archive entry fetched from {} for slot {slot} is invalid because it does not contain any externalized envelopes.",
scp_archive_storage.0
);
// remove the file since it's invalid.
scp_archive_storage.remove_file(slot);
continue
}

Expand All @@ -297,6 +299,8 @@ impl ScpMessageCollector {
// indicates that the data was taken from the archive
from_archive_map.insert(slot, ());

// remove the archive file after successfully retrieving envelopes
scp_archive_storage.remove_file(slot);
break
}
}
Expand Down Expand Up @@ -355,6 +359,8 @@ impl ScpMessageCollector {
_ => TransactionSetType::new(target_history_entry.tx_set.clone()),
};
tx_set_map.insert(slot, tx_set_type);
// remove the archive file after a txset has been found
tx_archive_storage.remove_file(slot);
break
} else {
tracing::warn!(
Expand Down
6 changes: 4 additions & 2 deletions clients/vault/src/oracle/storage/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ pub trait ArchiveStorage {
slot_index + ARCHIVE_NODE_LEDGER_BATCH - rest
}

fn remove_file(&self, target_slot: Slot) -> std::io::Result<()> {
fn remove_file(&self, target_slot: Slot) {
let (_, file) = self.get_url_and_file_name(target_slot);
fs::remove_file(file)
if let Err(e) = fs::remove_file(&file) {
tracing::warn!("remove_file(): failed to remove file {file} for slot {target_slot}: {e:?}");
}
}

fn read_file_xdr(filename: &str) -> Result<Vec<u8>, Error> {
Expand Down

0 comments on commit 9aafee4

Please # to comment.