fix(remote download): file path slashes incorrectly formated for remote download transfer if master and slave node use different path style (#2532)

pull/2557/head
Aaron Liu 2025-06-21 09:51:12 +08:00
parent 3de33aeb10
commit bdc0aafab0
3 changed files with 7 additions and 6 deletions

2
assets

@ -1 +1 @@
Subproject commit 0720c1a80069c6a0c14fce93efbc03417f249a67 Subproject commit 93d616e742d95ed666938d59200b872e98005527

View File

@ -319,7 +319,7 @@ func (m *RemoteDownloadTask) slaveTransfer(ctx context.Context, dep dependency.D
} }
dst := dstUri.JoinRaw(f.Name) dst := dstUri.JoinRaw(f.Name)
src := filepath.FromSlash(path.Join(m.state.Status.SavePath, f.Name)) src := path.Join(m.state.Status.SavePath, f.Name)
payload.Files = append(payload.Files, SlaveUploadEntity{ payload.Files = append(payload.Files, SlaveUploadEntity{
Src: src, Src: src,
Uri: dst, Uri: dst,

View File

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
"path"
"path/filepath" "path/filepath"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -127,11 +128,11 @@ func (t *SlaveUploadTask) Do(ctx context.Context) (task.Status, error) {
t.progress[progressKey] = &queue.Progress{Identifier: file.Uri.String(), Total: file.Size} t.progress[progressKey] = &queue.Progress{Identifier: file.Uri.String(), Total: file.Size}
t.Unlock() t.Unlock()
handle, err := os.Open(file.Src) handle, err := os.Open(filepath.FromSlash(file.Src))
if err != nil { if err != nil {
t.l.Warning("Failed to open file %s: %s", file.Src, err.Error()) t.l.Warning("Failed to open file %s: %s", file.Src, err.Error())
atomic.AddInt64(&t.progress[ProgressTypeUpload].Current, file.Size) atomic.AddInt64(&t.progress[ProgressTypeUpload].Current, file.Size)
ae.Add(filepath.Base(file.Src), fmt.Errorf("failed to open file: %w", err)) ae.Add(path.Base(file.Src), fmt.Errorf("failed to open file: %w", err))
return return
} }
@ -140,7 +141,7 @@ func (t *SlaveUploadTask) Do(ctx context.Context) (task.Status, error) {
t.l.Warning("Failed to get file stat for %s: %s", file.Src, err.Error()) t.l.Warning("Failed to get file stat for %s: %s", file.Src, err.Error())
handle.Close() handle.Close()
atomic.AddInt64(&t.progress[ProgressTypeUpload].Current, file.Size) atomic.AddInt64(&t.progress[ProgressTypeUpload].Current, file.Size)
ae.Add(filepath.Base(file.Src), fmt.Errorf("failed to get file stat: %w", err)) ae.Add(path.Base(file.Src), fmt.Errorf("failed to get file stat: %w", err))
return return
} }
@ -163,7 +164,7 @@ func (t *SlaveUploadTask) Do(ctx context.Context) (task.Status, error) {
handle.Close() handle.Close()
t.l.Warning("Failed to upload file %s: %s", file.Src, err.Error()) t.l.Warning("Failed to upload file %s: %s", file.Src, err.Error())
atomic.AddInt64(&t.progress[ProgressTypeUpload].Current, file.Size) atomic.AddInt64(&t.progress[ProgressTypeUpload].Current, file.Size)
ae.Add(filepath.Base(file.Src), fmt.Errorf("failed to upload file: %w", err)) ae.Add(path.Base(file.Src), fmt.Errorf("failed to upload file: %w", err))
return return
} }