Skip to content

Commit

Permalink
Merge branch 'next' into non-persist
Browse files Browse the repository at this point in the history
  • Loading branch information
de-sh authored May 1, 2023
2 parents 5093f9e + 0e86050 commit 0f8786d
Show file tree
Hide file tree
Showing 23 changed files with 1,266 additions and 115 deletions.
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

0 comments on commit 0f8786d

Please sign in to comment.