Skip to content

Commit

Permalink
more parts enforced for linux slash on remote connection #166 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Dec 27, 2023
1 parent 327e3bc commit 5ca34eb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/executor/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (ex *Remote) Upload(ctx context.Context, local, remote string, opts *UpDown

// upload each file matching the glob pattern. If no glob pattern is found, the file is matched as is
for _, match := range matches {
relPath, e := filepath.Rel(filepath.Dir(local), match)
relPath, e := filepath.Rel(path.Dir(local), match)
if e != nil {
return fmt.Errorf("failed to build relative path for %s: %w", match, err)
}
Expand All @@ -84,7 +84,7 @@ func (ex *Remote) Upload(ctx context.Context, local, remote string, opts *UpDown

remoteFile := remote
if len(matches) > 1 { // if there are multiple files, treat remote as a directory
remoteFile = path.Join(remote, filepath.Base(match))
remoteFile = path.Join(remote, path.Base(match))
}
req := sftpReq{
client: ex.client,
Expand Down Expand Up @@ -132,8 +132,8 @@ func (ex *Remote) Download(ctx context.Context, remote, local string, opts *UpDo

// if the remote basename does not equal the remoteFile basename,
// treat remote as a glob pattern and local as a directory
if filepath.Base(remote) != filepath.Base(remoteFile) {
localFile = path.Join(local, filepath.Base(remoteFile))
if path.Base(remote) != path.Base(remoteFile) {
localFile = path.Join(local, path.Base(remoteFile))
}

req := sftpReq{
Expand Down Expand Up @@ -392,7 +392,7 @@ func (ex *Remote) sftpUpload(ctx context.Context, req sftpReq) error {
}

if req.mkdir {
if e := sftpClient.MkdirAll(filepath.Dir(req.remoteFile)); e != nil {
if e := sftpClient.MkdirAll(path.Dir(req.remoteFile)); e != nil {
return fmt.Errorf("failed to create remote directory: %v", e)
}
}
Expand Down Expand Up @@ -639,7 +639,7 @@ func (ex *Remote) findMatchedFiles(remote string, excl []string) ([]string, erro

files := make([]string, 0, len(matches))
for _, match := range matches {
relPath, e := filepath.Rel(filepath.Dir(remote), match)
relPath, e := filepath.Rel(path.Dir(remote), match)
if e != nil {
return nil, fmt.Errorf("failed to build relative path for %s: %w", match, err)
}
Expand Down

0 comments on commit 5ca34eb

Please sign in to comment.