mirror of https://gogs.blitter.com/RLabs/xs
Fixes in progress for MSYS2/MINGW xc copy logic (single file works, not dirs yet)
This commit is contained in:
parent
003230ef62
commit
3a15fb8244
27
auth.go
27
auth.go
|
|
@ -215,18 +215,39 @@ func AuthUserByToken(ctx *AuthCtx, username string, connhostname string, auth st
|
|||
return
|
||||
}
|
||||
|
||||
func GroomFsPath(path string) (ret string) {
|
||||
pathRoot := os.Getenv("MINGW_ROOT")
|
||||
if pathRoot != "" {
|
||||
ret = path[len(pathRoot):]
|
||||
ret = strings.ReplaceAll(ret, "\\", "/")
|
||||
} else {
|
||||
ret = path
|
||||
}
|
||||
fmt.Printf("groomed fspath:%v\n", ret)
|
||||
return
|
||||
}
|
||||
|
||||
func GetTool(tool string) (ret string) {
|
||||
ret = "/bin/" + tool
|
||||
cmdSuffix := ""
|
||||
pathRoot := os.Getenv("MINGW_ROOT")
|
||||
|
||||
if pathRoot != "" {
|
||||
cmdSuffix = ".exe"
|
||||
}
|
||||
|
||||
fmt.Printf("pathRoot:%v cmdSuffix:%v\n", pathRoot, cmdSuffix)
|
||||
|
||||
ret = pathRoot + "/bin/" + tool + cmdSuffix
|
||||
_, err := os.Stat(ret)
|
||||
if err == nil {
|
||||
return ret
|
||||
}
|
||||
ret = "/usr/bin/" + tool
|
||||
ret = pathRoot + "/usr/bin/" + tool + cmdSuffix
|
||||
_, err = os.Stat(ret)
|
||||
if err == nil {
|
||||
return ret
|
||||
}
|
||||
ret = "/usr/local/bin/" + tool
|
||||
ret = pathRoot + "/usr/local/bin/" + tool + cmdSuffix
|
||||
_, err = os.Stat(ret)
|
||||
if err == nil {
|
||||
return ret
|
||||
|
|
|
|||
18
xs/xs.go
18
xs/xs.go
|
|
@ -294,7 +294,14 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
|||
|
||||
captureStderr = true
|
||||
cmd = xs.GetTool("tar")
|
||||
args = []string{"-cz", "-f", "/dev/stdout"}
|
||||
fmt.Printf("GetTool found cmd:%v\n", cmd)
|
||||
/* Explicit -f /dev/stdout doesn't work in MINGW/MSYS64
|
||||
* as '/dev/stdout' doesn't actually appear in the /dev/ filesystem...?
|
||||
* And it appears not to actually be required as without -f stdout is
|
||||
* implied. -rlm 2025-12-07
|
||||
*/
|
||||
//args = []string{"-cz", "-f", "/dev/stdout"}
|
||||
args = []string{"-cz"}
|
||||
files = strings.TrimSpace(files)
|
||||
// Awesome fact: tar actually can take multiple -C args, and
|
||||
// changes to the dest dir *as it sees each one*. This enables
|
||||
|
|
@ -310,6 +317,7 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
|||
// remote destDir.
|
||||
for _, v := range strings.Split(files, " ") {
|
||||
v, _ = filepath.Abs(v) // #nosec
|
||||
v = xs.GroomFsPath(v)
|
||||
dirTmp, fileTmp := path.Split(v)
|
||||
if dirTmp == "" {
|
||||
args = append(args, fileTmp)
|
||||
|
|
@ -322,7 +330,8 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
|||
bandwidthInBytesPerSec := " -L " + fmt.Sprintf("%d", copyLimitBPS)
|
||||
displayOpts := " -pre " //nolint:goconst,nolintlint
|
||||
cmd = xs.GetTool("bash")
|
||||
args = []string{"-c", xs.GetTool("tar") + " -cz -f /dev/stdout "}
|
||||
//args = []string{"-c", xs.GetTool("tar") + " -cz -f /dev/stdout "}
|
||||
args = []string{"-c", xs.GetTool("tar") + " -cz "}
|
||||
files = strings.TrimSpace(files)
|
||||
// Awesome fact: tar actually can take multiple -C args, and
|
||||
// changes to the dest dir *as it sees each one*. This enables
|
||||
|
|
@ -338,6 +347,7 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
|||
// remote destDir.
|
||||
for _, v := range strings.Split(files, " ") {
|
||||
v, _ = filepath.Abs(v) // #nosec
|
||||
v = xs.GroomFsPath(v)
|
||||
dirTmp, fileTmp := path.Split(v)
|
||||
if dirTmp == "" {
|
||||
args[1] = args[1] + fileTmp + " "
|
||||
|
|
@ -385,7 +395,9 @@ func doCopyMode(conn *xsnet.Conn, remoteDest bool, files string, copyQuiet bool,
|
|||
} else {
|
||||
c.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
|
||||
fmt.Printf("cmd:%v args:%v\n", cmdName, cmdArgs)
|
||||
|
||||
// Start the command (no pty)
|
||||
err = c.Start() // returns immediately
|
||||
/////////////
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func runClientToServerCopyAs(who, ttype string, conn *xsnet.Conn, fpath string,
|
|||
}
|
||||
|
||||
cmdArgs := []string{"-xz", "-C", destDir}
|
||||
|
||||
|
||||
// NOTE the lack of quotes around --xform option's sed expression.
|
||||
// When args are passed in exec() format, no quoting is required
|
||||
// (as this isn't input from a shell) (right? -rlm 20180823)
|
||||
|
|
|
|||
Loading…
Reference in New Issue