about summary refs log tree commit diff
path: root/tvix/store/src/blobservice
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-06-30T14·11+0200
committerclbot <clbot@tvl.fyi>2023-07-21T18·52+0000
commit638f3e874d5eb6c157ffd065e593ee1a8a14d3e0 (patch)
tree42382a0404bc7c0737bc223363d91e701ebbd5a8 /tvix/store/src/blobservice
parent7613e2e76972554ee2a5ae1397f8b5ca84f4f729 (diff)
feat(tvix/store/fuse): implement open explicitly r/6435
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 <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/store/src/blobservice')
-rw-r--r--tvix/store/src/blobservice/dumb_seeker.rs12
1 files changed, 11 insertions, 1 deletions
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<R: io::Read> io::Seek for DumbSeeker<R> {
                 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;