From 232e162f8c6ffc96abf0fcfdf124b7503a7082d5 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Thu, 4 Jul 2024 05:52:09 -0700 Subject: [PATCH] Sending folders from the root of a drive always goes to the same path on the receiver's end Fixes #574 --- src/croc/croc.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index 1a3d93a0..672524aa 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -421,8 +421,14 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool) (filesInfo [] if err != nil { return err } - remoteFolder := strings.TrimPrefix(filepath.Dir(pathName), - filepath.Dir(absPath)+string(os.PathSeparator)) + absPathWithSeparator := filepath.Dir(absPath) + if !strings.HasSuffix(absPathWithSeparator, string(os.PathSeparator)) { + absPathWithSeparator += string(os.PathSeparator) + } + if strings.HasSuffix(absPathWithSeparator, string(os.PathSeparator)+string(os.PathSeparator)) { + absPathWithSeparator = strings.TrimSuffix(absPathWithSeparator, string(os.PathSeparator)) + } + remoteFolder := strings.TrimPrefix(filepath.Dir(pathName), absPathWithSeparator) if !info.IsDir() { fInfo := FileInfo{ Name: info.Name(),