From 60517b259431b1e369073d06c03f189f302cdf4d Mon Sep 17 00:00:00 2001 From: aneesh-n <99904+aneesh-n@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:15:26 +0530 Subject: [PATCH] Add fix for volume name "C:" missed in merge --- internal/archiver/archiver_unix.go | 8 +++++++- internal/archiver/archiver_windows.go | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/archiver/archiver_unix.go b/internal/archiver/archiver_unix.go index 4309bb36b..3b42dcd72 100644 --- a/internal/archiver/archiver_unix.go +++ b/internal/archiver/archiver_unix.go @@ -19,7 +19,13 @@ func preProcessTargets(_ fs.FS, _ *[]string) { // processTarget processes each target in the loop. // In case of non-windows OS it uses the passed filesys to clean the target. func processTarget(filesys fs.FS, target string) string { - return filesys.Clean(target) + if target != "" && filesys.VolumeName(target) == target { + // special case to allow users to also specify a volume name "C:" instead of a path "C:\" + target = target + filesys.Separator() + } else { + target = filesys.Clean(target) + } + return target } // preProcessPaths processes paths before looping. diff --git a/internal/archiver/archiver_windows.go b/internal/archiver/archiver_windows.go index 719ce5fa5..bf997ea1b 100644 --- a/internal/archiver/archiver_windows.go +++ b/internal/archiver/archiver_windows.go @@ -31,7 +31,11 @@ func preProcessTargets(filesys fs.FS, targets *[]string) { // processTarget processes each target in the loop. // In case of windows the clean up of target is already done // in preProcessTargets before the loop, hence this is no-op. -func processTarget(_ fs.FS, target string) string { +func processTarget(filesys fs.FS, target string) string { + if target != "" && filesys.VolumeName(target) == target { + // special case to allow users to also specify a volume name "C:" instead of a path "C:\" + target = target + filesys.Separator() + } return target }