Skip to content

Commit b9fa9db

Browse files
committed
cstorage: Strip sha256: prefix from image IDs
Image IDs from `podman build --iidfile` include the `sha256:` prefix, but containers-storage directories use just the hex digest. Strip the prefix when opening images to support both formats. Fixes CI failure where `cfsctl oci pull containers-storage:sha256:...` failed with "image not found". See containers/skopeo#2750 Assisted-by: OpenCode (Opus 4.5)
1 parent 455891a commit b9fa9db

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

crates/cstorage/src/image.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,19 @@ pub struct Image {
4646
impl Image {
4747
/// Open an image by ID using fd-relative operations.
4848
///
49+
/// The ID can be provided with or without a `sha256:` prefix - the prefix
50+
/// will be stripped if present, since containers-storage directories use
51+
/// just the hex digest.
52+
///
4953
/// # Errors
5054
///
5155
/// Returns an error if the image directory doesn't exist or cannot be opened.
5256
pub fn open(storage: &Storage, id: &str) -> Result<Self> {
57+
// Strip the sha256: prefix if present - containers-storage directories
58+
// use just the hex digest, but image IDs from podman (e.g. via --iidfile)
59+
// include the prefix. See https://github.com/containers/skopeo/issues/2750
60+
let id = id.strip_prefix("sha256:").unwrap_or(id);
61+
5362
// Open overlay-images directory from storage root
5463
let images_dir = storage.root_dir().open_dir("overlay-images")?;
5564

0 commit comments

Comments
 (0)