From 24b017f4f14351f7c466edcd85bad17224583277 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 15 Sep 2021 10:00:56 -0700 Subject: [PATCH] Properly handle import dest being a directory (thanks @elguero!) --- internal/app/wwctl/overlay/imprt/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/app/wwctl/overlay/imprt/main.go b/internal/app/wwctl/overlay/imprt/main.go index c4907702..2c31ab6b 100644 --- a/internal/app/wwctl/overlay/imprt/main.go +++ b/internal/app/wwctl/overlay/imprt/main.go @@ -44,6 +44,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error { os.Exit(1) } + if util.IsDir(path.Join(overlaySource, dest)) { + dest = path.Join(dest, path.Base(source)) + } + if util.IsFile(path.Join(overlaySource, dest)) { wwlog.Printf(wwlog.ERROR, "A file with that name already exists in the %s overlay %s\n:", overlayKind, overlayName) os.Exit(1)