mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-03 16:41:26 +01:00
fmt
This commit is contained in:
1 parent
81a0ecce54
commit
ec4f5ea32f
2 files changed
+36
-10
No files matched your search
@@ -206,7 +206,8 @@ impl ContentCache {
|
||||
}
|
||||
|
||||
fn block_meta(&self, uid: &NodeUid, idx: u64) -> PathBuf {
|
||||
self.block_dir.join(format!("{}.b{idx}.meta", Self::key(uid)))
|
||||
self.block_dir
|
||||
.join(format!("{}.b{idx}.meta", Self::key(uid)))
|
||||
}
|
||||
|
||||
/// Serve cached block `idx` (a [`BLOCK_SIZE`]-aligned chunk) of `uid`, or
|
||||
@@ -244,7 +245,10 @@ impl ContentCache {
|
||||
.join(format!("{}.b{idx}.tmp", Self::key(uid)));
|
||||
std::fs::write(&tmp, bytes)?;
|
||||
std::fs::rename(&tmp, &blob)?;
|
||||
std::fs::write(self.block_meta(uid, idx), serde_json::to_vec(&Meta { mtime, size })?)?;
|
||||
std::fs::write(
|
||||
self.block_meta(uid, idx),
|
||||
serde_json::to_vec(&Meta { mtime, size })?,
|
||||
)?;
|
||||
self.enforce_block_budget();
|
||||
Ok(())
|
||||
}
|
||||
@@ -744,7 +748,10 @@ mod tests {
|
||||
assert!(c.cached_block(&u, 1, 12, 0).is_some());
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
c.store_block(&u, 1, 12, 2, b"cccc").unwrap();
|
||||
assert!(c.cached_block(&u, 1, 12, 0).is_some(), "recently-read survives");
|
||||
assert!(
|
||||
c.cached_block(&u, 1, 12, 0).is_some(),
|
||||
"recently-read survives"
|
||||
);
|
||||
assert!(c.cached_block(&u, 1, 12, 1).is_none(), "LRU block evicted");
|
||||
assert!(c.cached_block(&u, 1, 12, 2).is_some(), "newest survives");
|
||||
}
|
||||
|
||||
@@ -450,7 +450,13 @@ impl Core {
|
||||
} else {
|
||||
let bend = e.min(base_size);
|
||||
if s < bend {
|
||||
out.extend_from_slice(&self.read_range(uid, base_mtime, base_size, s, bend - s)?);
|
||||
out.extend_from_slice(&self.read_range(
|
||||
uid,
|
||||
base_mtime,
|
||||
base_size,
|
||||
s,
|
||||
bend - s,
|
||||
)?);
|
||||
}
|
||||
// Anything past the base is a hole: zero-fill.
|
||||
let zeros = e.saturating_sub(s.max(base_size));
|
||||
@@ -510,10 +516,13 @@ impl Core {
|
||||
Errno::EIO
|
||||
})?;
|
||||
self.rt
|
||||
.block_on(
|
||||
self.client
|
||||
.upload_new_revision_from(&uid, reader, len as i64, Vec::new(), None),
|
||||
)
|
||||
.block_on(self.client.upload_new_revision_from(
|
||||
&uid,
|
||||
reader,
|
||||
len as i64,
|
||||
Vec::new(),
|
||||
None,
|
||||
))
|
||||
.map_err(|e| {
|
||||
error!(%uid, error = %e, "upload new revision failed");
|
||||
Errno::EIO
|
||||
@@ -1123,7 +1132,14 @@ impl Filesystem for ProtonFs {
|
||||
};
|
||||
if let Some((file, len, uid, base_mtime, base_size, written)) = handle {
|
||||
match self.core.serve_open_read(
|
||||
&file, len, &uid, base_mtime, base_size, &written, offset, size as u64,
|
||||
&file,
|
||||
len,
|
||||
&uid,
|
||||
base_mtime,
|
||||
base_size,
|
||||
&written,
|
||||
offset,
|
||||
size as u64,
|
||||
) {
|
||||
Ok(bytes) => reply.data(&bytes),
|
||||
Err(e) => reply.error(e),
|
||||
@@ -1146,7 +1162,10 @@ impl Filesystem for ProtonFs {
|
||||
}
|
||||
}
|
||||
};
|
||||
match self.core.read_range(&uid, mtime, fsize, offset, size as u64) {
|
||||
match self
|
||||
.core
|
||||
.read_range(&uid, mtime, fsize, offset, size as u64)
|
||||
{
|
||||
Ok(bytes) => reply.data(&bytes),
|
||||
Err(e) => reply.error(e),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user