From 639e54e8363711209f4cfac1008aaf0bb34d5c16 Mon Sep 17 00:00:00 2001 From: Sebastian Thees Date: Fri, 30 Jan 2026 08:54:00 +0100 Subject: [PATCH] oci2disk: fail fast if the given destinationDevice (via env DEST_DISK) does not exist. otherwise the action waits for a very long time. maybe the os.O_CREATE is not necessary as would fix this, too, see image2disk action. However, checking before opening is a sure fix. Signed-off-by: Sebastian Thees --- oci2disk/image/image.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oci2disk/image/image.go b/oci2disk/image/image.go index 01a1855e..8d9e5d7c 100644 --- a/oci2disk/image/image.go +++ b/oci2disk/image/image.go @@ -52,6 +52,11 @@ func Write(sourceImage, destinationDevice string, compressed bool) error { resolver := docker.NewResolver(opts) + // Check that the destination device exists before attempting to open it. + if _, err := os.Stat(destinationDevice); err != nil { + return fmt.Errorf("destination device %s does not exist", destinationDevice) + } + fileOut, err := os.OpenFile(destinationDevice, os.O_CREATE|os.O_WRONLY, 0o644) if err != nil { return err