diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-01-03 14:51:13 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-01-03 14:51:13 -0600 |
| commit | b1ffa39a060d68d162e3348e339dc2ea1163ff28 (patch) | |
| tree | 2274c655b354b94c8dfc128aae77e8844ece2fe7 | |
| parent | c1d3dea4f77d0ebebc27877ed5a3540fef2e96fd (diff) | |
Fix forget requests (it was expecting proto::ForgetOne instead of proto::ForgetIn)
| -rw-r--r-- | src/fuse/ops.rs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/fuse/ops.rs b/src/fuse/ops.rs index 6bb307a..1e22717 100644 --- a/src/fuse/ops.rs +++ b/src/fuse/ops.rs @@ -99,7 +99,7 @@ op! { Forget { type RequestBody = proto::OpcodeSelect< (&'o proto::BatchForgetIn, &'o [proto::ForgetOne]), - &'o proto::ForgetOne, + &'o proto::ForgetIn, { proto::Opcode::BatchForget as u32 }, >; @@ -110,12 +110,29 @@ op! { pub fn forget_list(&self) -> impl '_ + Iterator<Item = (Ino, u64)> { use proto::OpcodeSelect::*; - let slice = match self.body { - Match((_, slice)) => slice, - Alt(single) => std::slice::from_ref(single), - }; + enum List<'a> { + Single(Option<(Ino, u64)>), + Batch(std::slice::Iter<'a, proto::ForgetOne>), + } - slice.iter().map(|forget| (Ino(forget.ino), forget.nlookup)) + impl Iterator for List<'_> { + type Item = (Ino, u64); + + fn next(&mut self) -> Option<Self::Item> { + match self { + List::Single(single) => single.take(), + List::Batch(batch) => { + let forget = batch.next()?; + Some((Ino(forget.ino), forget.nlookup)) + } + } + } + } + + match self.body { + Match((_, slice)) => List::Batch(slice.iter()), + Alt(single) => List::Single(Some((self.ino(), single.nlookup))), + } } } |
