Skip to content

Commit

Permalink
Do not drop AppendVec in store-tool (#32739)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Aug 7, 2023
1 parent 6eea38d commit 6ce647a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions runtime/store-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
hash::Hash,
pubkey::Pubkey,
},
std::mem::ManuallyDrop,
};

fn main() {
Expand Down Expand Up @@ -34,8 +35,11 @@ fn main() {
let len = value_t!(matches, "len", usize)
.unwrap_or_else(|_| std::fs::metadata(&file).unwrap().len() as usize);

let mut store = AppendVec::new_from_file_unchecked(file, len).expect("should succeed");
store.set_no_remove_on_drop();
// When the AppendVec is dropped, the backing file will be removed. We do not want to remove
// the backing file here in the store-tool, so prevent dropping.
let store = ManuallyDrop::new(
AppendVec::new_from_file_unchecked(file, len).expect("new AppendVec from file"),
);
info!("store: len: {} capacity: {}", store.len(), store.capacity());
let mut num_accounts: usize = 0;
let mut stored_accounts_len: usize = 0;
Expand Down Expand Up @@ -67,6 +71,3 @@ fn is_account_zeroed(account: &StoredAccountMeta) -> bool {
&& account.pubkey() == &Pubkey::default()
&& account.to_account_shared_data() == AccountSharedData::default()
}

#[cfg(test)]
pub mod test {}

0 comments on commit 6ce647a

Please sign in to comment.