Skip to content

Commit dc84be3

Browse files
committed
fix: path handling for cross-platform and guest paths
- Fix inconsistent path separator handling on Windows - Use path.Join for guest paths (always forward slashes) - Update hypeman-go dependency
1 parent 31882f5 commit dc84be3

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/gorilla/websocket v1.5.3
1313
github.com/itchyny/json2yaml v0.1.4
1414
github.com/muesli/reflow v0.3.0
15-
github.com/onkernel/hypeman-go v0.7.1-0.20251223013311-b97d5b836009
15+
github.com/onkernel/hypeman-go v0.7.1-0.20251223015448-3fc21a9216cf
1616
github.com/tidwall/gjson v1.18.0
1717
github.com/tidwall/pretty v1.2.1
1818
github.com/urfave/cli-docs/v3 v3.0.0-alpha6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
105105
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
106106
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
107107
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
108-
github.com/onkernel/hypeman-go v0.7.1-0.20251223013311-b97d5b836009 h1:LPFxYVNAEv4reF4ZFzd45rLPLRWr60NPaPIb0Z622X0=
109-
github.com/onkernel/hypeman-go v0.7.1-0.20251223013311-b97d5b836009/go.mod h1:Wtm4ewVGGPZc2ySeeuQISQyJxujyQuyDjXyksVkIyy8=
108+
github.com/onkernel/hypeman-go v0.7.1-0.20251223015448-3fc21a9216cf h1:vGNpWu/QZcBXqzeRx1qV/jN8JPGqveWn/xsqbrlQv1A=
109+
github.com/onkernel/hypeman-go v0.7.1-0.20251223015448-3fc21a9216cf/go.mod h1:Wtm4ewVGGPZc2ySeeuQISQyJxujyQuyDjXyksVkIyy8=
110110
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
111111
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
112112
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=

pkg/cmd/cp.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net/http"
1111
"net/url"
1212
"os"
13+
"path"
1314
"path/filepath"
1415
"strings"
1516
"time"
@@ -342,9 +343,12 @@ func resolveDestPath(ctx context.Context, baseURL, apiKey, instanceID, srcPath,
342343
}
343344

344345
// Check if dstPath ends with /. (copy contents only)
345-
copyContentsOnly := strings.HasSuffix(srcPath, string(filepath.Separator)+".")
346+
// Handle both OS-specific separator and forward slash for cross-platform compatibility
347+
copyContentsOnly := strings.HasSuffix(srcPath, string(filepath.Separator)+".") ||
348+
strings.HasSuffix(srcPath, "/.")
346349
if copyContentsOnly {
347350
srcPath = strings.TrimSuffix(srcPath, string(filepath.Separator)+".")
351+
srcPath = strings.TrimSuffix(srcPath, "/.")
348352
}
349353

350354
// Check if destination ends with /
@@ -380,7 +384,8 @@ func resolveDestPath(ctx context.Context, baseURL, apiKey, instanceID, srcPath,
380384
}
381385
if dstStat.IsDir {
382386
// Copy into directory using basename
383-
return filepath.Join(dstPath, filepath.Base(srcPath)), nil
387+
// Use path.Join for guest paths (always forward slashes)
388+
return path.Join(dstPath, filepath.Base(srcPath)), nil
384389
}
385390
// Overwrite file
386391
return dstPath, nil
@@ -403,7 +408,8 @@ func resolveDestPath(ctx context.Context, baseURL, apiKey, instanceID, srcPath,
403408
}
404409

405410
// Copy SRC dir into DEST (create subdir)
406-
return filepath.Join(dstPath, filepath.Base(srcPath)), nil
411+
// Use path.Join for guest paths (always forward slashes)
412+
return path.Join(dstPath, filepath.Base(srcPath)), nil
407413
}
408414

409415
// buildCpWsURL builds the WebSocket URL for the cp endpoint
@@ -549,7 +555,8 @@ func copyDirContentsToInstance(ctx context.Context, baseURL, apiKey, instanceID,
549555

550556
for _, entry := range entries {
551557
srcEntryPath := filepath.Join(srcPath, entry.Name())
552-
dstEntryPath := filepath.Join(dstPath, entry.Name())
558+
// Use path.Join for guest paths (always forward slashes)
559+
dstEntryPath := path.Join(dstPath, entry.Name())
553560

554561
info, err := entry.Info()
555562
if err != nil {

0 commit comments

Comments
 (0)