Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

514 Remove archive files after use #515

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading