Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: tool to analyze backlog files in persistence #208

Merged
merged 12 commits into from
Apr 28, 2023
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ members = [
"disk",
]
exclude = [
"tools/deserialize-backup",
"tools/simulator",
"tools/tunshell",
"tools/utils",
"tools/simulator",
]

[profile.dev]
Expand Down
8 changes: 8 additions & 0 deletions disk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct Storage {
current_read_file: BytesMut,
/// id of file being read, delete it on read completion
current_read_file_id: Option<u64>,
/// run through persistence without deleting files
pub non_destructive_read: bool,
}

impl Storage {
Expand All @@ -52,6 +54,7 @@ impl Storage {
current_write_file: BytesMut::with_capacity(max_file_size * 2),
current_read_file: BytesMut::with_capacity(max_file_size * 2),
current_read_file_id: None,
non_destructive_read: false,
})
}

Expand All @@ -77,8 +80,13 @@ impl Storage {

/// Removes a file with provided id
fn remove(&self, id: u64) -> Result<(), Error> {
if self.non_destructive_read {
return Ok(());
}

let path = self.get_read_file_path(id)?;
fs::remove_file(path)?;

Ok(())
}

Expand Down
Loading