Skip to content

Commit d27f6f2

Browse files
Nishant GauravNishant Gaurav
authored andcommitted
fix: correct destination path to prevent
duplicate filenames in ls output
1 parent 2f37d20 commit d27f6f2

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

cmd/add.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,19 @@ Examples:
205205
// For directories, preserve the structure
206206
relPath, err := filepath.Rel(pair.Source, sourceFile)
207207
if err != nil {
208-
// If we can't get relative path, use just the filename
209-
destPath = filepath.Join(pair.Destination, filepath.Base(sourceFile))
208+
// If we can't get relative path, use just the destination directory
209+
destPath = pair.Destination
210210
} else {
211-
destPath = filepath.Join(pair.Destination, relPath)
211+
// Destination should be directory only (excluding the filename)
212+
// The FilePath field in manifest will have the filename
213+
destPath = filepath.Join(pair.Destination, filepath.Dir(relPath))
214+
// Ensure it ends with / for directory paths
215+
if destPath != "" && !strings.HasSuffix(destPath, "/") {
216+
destPath += "/"
217+
}
212218
}
213219
} else {
220+
// For single files, destination is the directory
214221
destPath = pair.Destination
215222
}
216223

0 commit comments

Comments
 (0)