From 1d536b166254e686fa63291503a4daf1a425a085 Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Fri, 29 Mar 2024 22:25:15 +0000 Subject: [PATCH] container-image: fix checkout --- vendor/container-image/src/checkout.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vendor/container-image/src/checkout.ml b/vendor/container-image/src/checkout.ml index 9002f9bc..0d9c1437 100644 --- a/vendor/container-image/src/checkout.ml +++ b/vendor/container-image/src/checkout.ml @@ -35,9 +35,12 @@ let checkout_layer ~sw ~cache layer dir = let file_mode = hdr.file_mode in let () = match hdr.link_indicator with - | Directory -> Eio.Path.mkdir ~perm:file_mode path + | Directory -> (try Eio.Path.mkdir ~perm:file_mode path with Eio.Exn.Io (Eio.Fs.E Already_exists _, _) -> ()) | Symbolic -> - Eio_unix.run_in_systhread ~label:"symlink" (fun () -> Unix.symlink hdr.link_name (Eio.Path.native_exn path)) + Eio_unix.run_in_systhread ~label:"symlink" (fun () -> + try Unix.symlink hdr.link_name (Eio.Path.native_exn path) with + Unix.Unix_error (Unix.EEXIST, _, _) -> () + ) | _ -> Eio.Switch.run @@ fun sw -> let dst = @@ -67,13 +70,12 @@ let checkout_layers ?(top_layer=false) ~sw ~cache ~dir layers = | [ layer ] -> let d = Descriptor.digest layer in checkout_layer ~sw ~cache d dir - | layer :: _ when top_layer -> - let d = Descriptor.digest layer in - checkout_layer ~sw ~cache d dir | layers -> List.iteri (fun i layer -> - let dir = Eio.Path.(dir / string_of_int i) in + let dir = + if top_layer then dir else + Eio.Path.(dir / string_of_int i) in let d = Descriptor.digest layer in checkout_layer ~sw ~cache d dir) layers