Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
radumarias committed Aug 26, 2024
2 parents 78abee8 + 166475d commit 1b59da1
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/encryptedfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ impl EncryptedFs {
self.contents_path(ino).is_file()
}

#[allow(dead_code)]
async fn is_read_only(&self) -> bool {
self.read_only
}
Expand All @@ -676,7 +677,7 @@ impl EncryptedFs {
if self.exists_by_name(parent, name)? {
return Err(FsError::AlreadyExists);
}
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}

Expand Down Expand Up @@ -873,7 +874,7 @@ impl EncryptedFs {
if !self.is_dir(parent) {
return Err(FsError::InvalidInodeType);
}
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}

Expand Down Expand Up @@ -953,7 +954,7 @@ impl EncryptedFs {
if !self.exists_by_name(parent, name)? {
return Err(FsError::NotFound("name not found"));
}
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}

Expand Down Expand Up @@ -1494,7 +1495,7 @@ impl EncryptedFs {
// write
let ctx = { self.write_handles.write().await.remove(&handle) };
if let Some(ctx) = ctx {
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}
let mut ctx = ctx.lock().await;
Expand Down Expand Up @@ -1591,7 +1592,7 @@ impl EncryptedFs {
return Err(FsError::InvalidFileHandle);
}
}
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}
{
Expand Down Expand Up @@ -1692,7 +1693,7 @@ impl EncryptedFs {
// in the case of directory or if the file was crated without being opened we don't use a handle
return Ok(());
}
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}
let lock = self.read_handles.read().await;
Expand Down Expand Up @@ -1735,7 +1736,7 @@ impl EncryptedFs {
if self.is_dir(src_ino) || self.is_dir(dest_ino) {
return Err(FsError::InvalidInodeType);
}
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}

Expand All @@ -1761,7 +1762,7 @@ impl EncryptedFs {
/// Open a file. We can open multiple times for read but only one to write at a time.
#[allow(clippy::missing_panics_doc)]
pub async fn open(&self, ino: u64, read: bool, write: bool) -> FsResult<u64> {
if write && self.is_read_only().await {
if write && self.read_only {
return Err(FsError::ReadOnly);
}
if !read && !write {
Expand Down Expand Up @@ -1828,7 +1829,7 @@ impl EncryptedFs {
#[allow(clippy::missing_panics_doc)]
#[allow(clippy::too_many_lines)]
pub async fn set_len(&self, ino: u64, size: u64) -> FsResult<()> {
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}
info!("truncate {ino} to {size}");
Expand Down Expand Up @@ -1920,7 +1921,7 @@ impl EncryptedFs {
/// > That is because we want to make sure caller is holding a lock while all writers flush and we can't
/// > lock here also as we would end-up in a deadlock.
async fn flush_and_reset_writers(&self, ino: u64) -> FsResult<()> {
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}
let opened_files_for_write_guard = self.opened_files_for_write.read().await;
Expand Down Expand Up @@ -1968,7 +1969,7 @@ impl EncryptedFs {
new_parent: u64,
new_name: &SecretString,
) -> FsResult<()> {
if self.is_read_only().await {
if self.read_only {
return Err(FsError::ReadOnly);
}
if !self.exists(parent) {
Expand Down

0 comments on commit 1b59da1

Please sign in to comment.