Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"path"
"path/filepath"
"strings"
"syscall"
"time"

"github.com/gorilla/websocket"
Expand Down Expand Up @@ -183,10 +182,7 @@ func cpToInstanceInternal(ctx context.Context, cfg CpConfig, opts CpToInstanceOp
// Get UID/GID if archive mode is enabled
var uid, gid uint32
if opts.Archive {
if stat, ok := srcInfo.Sys().(*syscall.Stat_t); ok {
uid = stat.Uid
gid = stat.Gid
}
uid, gid = getFileOwnership(srcInfo)
}

// Send initial request
Expand Down
16 changes: 16 additions & 0 deletions lib/stat_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build unix

package lib

import (
"io/fs"
"syscall"
)

// getFileOwnership returns the UID and GID of a file on Unix systems.
func getFileOwnership(info fs.FileInfo) (uid, gid uint32) {
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
return stat.Uid, stat.Gid
}
return 0, 0
}
10 changes: 10 additions & 0 deletions lib/stat_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build windows

package lib

import "io/fs"

// getFileOwnership returns 0, 0 on Windows as UID/GID are Unix concepts.
func getFileOwnership(info fs.FileInfo) (uid, gid uint32) {
return 0, 0
}