Skip to content

Commit 7263032

Browse files
committed
repository: Add some error context
This adds error context when opening images and streams. Without this it is kinda hard to figure out what ENOENT really means. Signed-off-by: Alexander Larsson <[email protected]>
1 parent ff39d80 commit 7263032

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/composefs/src/repository.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,11 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
332332
let filename = format!("streams/{name}");
333333

334334
let file = File::from(if let Some(verity_hash) = verity {
335-
self.open_with_verity(&filename, verity_hash)?
335+
self.open_with_verity(&filename, verity_hash)
336+
.with_context(|| format!("Opening ref 'streams/{name}'"))?
336337
} else {
337-
self.openat(&filename, OFlags::RDONLY)?
338+
self.openat(&filename, OFlags::RDONLY)
339+
.with_context(|| format!("Opening ref 'streams/{name}'"))?
338340
});
339341

340342
SplitStreamReader::new(file)
@@ -385,7 +387,9 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
385387
}
386388

387389
pub fn open_image(&self, name: &str) -> Result<OwnedFd> {
388-
let image = self.openat(&format!("images/{name}"), OFlags::RDONLY)?;
390+
let image = self
391+
.openat(&format!("images/{name}"), OFlags::RDONLY)
392+
.with_context(|| format!("Opening ref 'images/{name}'"))?;
389393

390394
if !name.contains("/") {
391395
// A name with no slashes in it is taken to be a sha256 fs-verity digest

0 commit comments

Comments
 (0)