From 638f3e874d5eb6c157ffd065e593ee1a8a14d3e0 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 30 Jun 2023 16:11:13 +0200 Subject: feat(tvix/store/fuse): implement open explicitly This "reverts" commit 9f600de22671ee1f88e6fb9e53a5a385b434871b (the initial revert of f5e291cf8328096d790f5416cf1968cb9164220a). Now with BlobService returning a BlobReader that implements io::Seek, we can actually just call blob_reader.seek(io::SeekFrom::Start(offset as u64)). This means, we currently will fail to seek backwards inside a file. Change-Id: I9c19448df6831a3537252f99210374f2126ecfc0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8886 Tested-by: BuildkiteCI Autosubmit: flokli Reviewed-by: raitobezarius --- tvix/store/src/blobservice/dumb_seeker.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tvix/store/src/blobservice/dumb_seeker.rs') diff --git a/tvix/store/src/blobservice/dumb_seeker.rs b/tvix/store/src/blobservice/dumb_seeker.rs index 5548ea0bd33d..8629394d21bc 100644 --- a/tvix/store/src/blobservice/dumb_seeker.rs +++ b/tvix/store/src/blobservice/dumb_seeker.rs @@ -80,7 +80,17 @@ impl io::Seek for DumbSeeker { Err(e) => return Err(e), } } - debug_assert_eq!(bytes_to_skip, bytes_skipped); + + // This will fail when seeking past the end of self.r + if bytes_to_skip != bytes_skipped { + return Err(std::io::Error::new( + std::io::ErrorKind::UnexpectedEof, + format!( + "tried to skip {} bytes, but only was able to skip {} until reaching EOF", + bytes_to_skip, bytes_skipped + ), + )); + } self.pos = absolute_offset; -- cgit 1.4.1