Skip to content

Commit bd4f90c

Browse files
committed
fix(cp): implement copyContentsOnly for from-instance operations
When copying a directory from instance to local, the /. suffix (copy contents only) was computed but not used. Now: - Without /.: creates source directory inside destination (docker cp semantics) - With /.: copies contents directly into destination
1 parent 04713b9 commit bd4f90c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/cmd/cp.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,13 @@ func copyFromInstance(ctx context.Context, client *hypeman.Client, baseURL, apiK
650650
return fmt.Errorf("cannot copy a directory to a file")
651651
}
652652
if !dstExists {
653-
// Create destination directory
653+
// Create destination directory - will be created by SDK
654654
} else if !copyContentsOnly {
655-
// Copy SRC dir into DST - the relative path from guest will be joined
656-
// The guest sends paths relative to srcPath basename, so we keep dstPath as-is
655+
// Copy SRC dir into DST - create source directory inside destination
656+
// Use path.Base for guest srcPath (always forward slashes)
657+
resolvedDst = filepath.Join(dstPath, path.Base(srcPath))
657658
}
659+
// else: copyContentsOnly=true - contents go directly into dstPath
658660
}
659661
dstPath = resolvedDst
660662

0 commit comments

Comments
 (0)