Skip to content

Commit 54e548d

Browse files
paskalumputun
authored andcommitted
Fix filepath.Rel error wrap to include the actual error
The glob loops in Local.Upload, Remote.Upload and findMatchedFiles wrapped the outer err (nil at that point) instead of the local e returned by filepath.Rel, so a rel failure would render %!w(<nil>) and lose the cause. Diagnostic-only, no behaviour change. Follow-up to review feedback on #352.
1 parent 7108a70 commit 54e548d

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

pkg/executor/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (l *Local) Upload(_ context.Context, src, dst string, opts *UpDownOpts) (er
9696
for _, match := range matches {
9797
relPath, e := filepath.Rel(filepath.Dir(src), match)
9898
if e != nil {
99-
return fmt.Errorf("failed to build relative path for %s: %w", match, err)
99+
return fmt.Errorf("failed to build relative path for %s: %w", match, e)
100100
}
101101
// check source file info; check exclusion before the stat error so an excluded broken symlink
102102
// is skipped instead of failing the whole upload

pkg/executor/remote.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (ex *Remote) Upload(ctx context.Context, local, remote string, opts *UpDown
7575
for _, match := range matches {
7676
relPath, e := filepath.Rel(filepath.Dir(local), match)
7777
if e != nil {
78-
return fmt.Errorf("failed to build relative path for %s: %w", match, err)
78+
return fmt.Errorf("failed to build relative path for %s: %w", match, e)
7979
}
8080
// matches are local paths, stat them so directory excludes (e.g. "subdir/*") skip a matched directory
8181
matchInfo, statErr := os.Stat(match)
@@ -674,7 +674,7 @@ func (ex *Remote) findMatchedFiles(remote string, excl []string) ([]string, erro
674674
for _, match := range matches {
675675
relPath, e := filepath.Rel(filepath.Dir(remote), match)
676676
if e != nil {
677-
return nil, fmt.Errorf("failed to build relative path for %s: %w", match, err)
677+
return nil, fmt.Errorf("failed to build relative path for %s: %w", match, e)
678678
}
679679
// matches are remote paths, stat them so directory excludes (e.g. "subdir/*") skip a matched directory
680680
matchInfo, statErr := sftpClient.Stat(match)

0 commit comments

Comments
 (0)