mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-19 01:55:04 +01:00
fix(fuse): queue pdfs rename and move behind the mount's changes (B149)
With changes through the mount queued, `pdfs rename` and `pdfs move` went straight to Drive ahead of a rename the mount still had queued, which then landed and put its name back: the account run's B121 case on every on-demand mount. They are now queued whenever the mount would queue, or the node has anything queued, and rewrite a still-queued create's target. The B113 acceptance case no longer requires creates to reach Drive at once; under local-first they are queued and the moves rewrite them.
This commit is contained in:
1 parent
9b2b9f24c5
commit
50ae25bb88
6 files changed
+306
-19
No files matched your search
@@ -129,6 +129,15 @@ impl Daemon {
|
||||
}
|
||||
}
|
||||
|
||||
/// Send one control request, as the `pdfs` CLI does, and fail on a
|
||||
/// refusal.
|
||||
pub(crate) fn request(&self, request: &Request) -> io::Result<Response> {
|
||||
match control::send(&self.socket, request).map_err(io::Error::other)? {
|
||||
Response::Error { message, .. } => Err(io::Error::other(message)),
|
||||
response => Ok(response),
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop the daemon and start it again on the same state and link.
|
||||
pub(crate) fn restart(mut self) -> io::Result<Self> {
|
||||
self.shut_down()?;
|
||||
@@ -466,6 +475,65 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "mounts FUSE: run with `cargo test -p pdfs-fuse sim:: -- --ignored`"]
|
||||
fn a_pdfs_rename_after_a_queued_rename_is_not_undone() {
|
||||
// `pdfs rename` and `pdfs move` went straight to Drive, and the
|
||||
// mount's own rename, still queued, landed after them and put the old
|
||||
// name back (B149, the account run's B121 case).
|
||||
let drive = FakeDrive::new();
|
||||
let dir = scratch("pdfs-rename-after-queued");
|
||||
let daemon = Daemon::start(&dir, drive.client(1, Faults::lan())).unwrap();
|
||||
|
||||
let mount = &daemon.mountpoint;
|
||||
std::fs::create_dir_all(mount.join("b/inner")).unwrap();
|
||||
std::fs::write(mount.join("b/first.txt"), b"moved").unwrap();
|
||||
let file = |bytes: &[u8]| Some(Entry::File(Arc::new(bytes.to_vec())));
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
drive.tree().get("b/first.txt").cloned() == file(b"moved")
|
||||
}));
|
||||
|
||||
let paused = |paused| Request::SetSyncPaused {
|
||||
paused,
|
||||
until: None,
|
||||
};
|
||||
daemon.request(&paused(true)).unwrap();
|
||||
std::fs::rename(mount.join("b/first.txt"), mount.join("b/back.txt")).unwrap();
|
||||
let path = |rel: &str| mount.join(rel).to_string_lossy().into_owned();
|
||||
daemon
|
||||
.request(&Request::Rename {
|
||||
path: path("b/back.txt"),
|
||||
new_name: "first.txt".into(),
|
||||
})
|
||||
.unwrap();
|
||||
daemon
|
||||
.request(&Request::Move {
|
||||
path: path("b/first.txt"),
|
||||
new_parent: path("b/inner"),
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
std::fs::read(mount.join("b/inner/first.txt")).unwrap(),
|
||||
b"moved"
|
||||
);
|
||||
daemon.request(&paused(false)).unwrap();
|
||||
|
||||
assert!(
|
||||
wait_until(Duration::from_secs(30), || {
|
||||
let tree = drive.tree();
|
||||
tree.get("b/inner/first.txt").cloned() == file(b"moved")
|
||||
&& daemon.pending().is_ok_and(|ops| ops.is_empty())
|
||||
}),
|
||||
"{:?}",
|
||||
drive.tree().keys().collect::<Vec<_>>()
|
||||
);
|
||||
let tree = drive.tree();
|
||||
assert!(!tree.contains_key("b/back.txt") && !tree.contains_key("b/inner/back.txt"));
|
||||
|
||||
assert!(matches!(daemon.stop(), Ok(MountOutcome::Shutdown)));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// Make 100 folders of 10 empty files each through a mount on `faults`, and
|
||||
/// time the syscalls and then the drain until Drive holds all of it.
|
||||
fn time_a_thousand_files(faults: Faults) -> (Duration, Duration) {
|
||||
|
||||
Reference in new issue
Block a user