mirror of
				https://github.com/cloudreve/cloudreve.git
				synced 2025-10-31 08:39:10 +08:00 
			
		
		
		
	fix(remote download): file path slashes incorrectly formated for remote download transfer if master and slave node use different path style (#2532)
This commit is contained in:
		
							
								
								
									
										2
									
								
								assets
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								assets
									
									
									
									
									
								
							 Submodule assets updated: 0720c1a800...93d616e742
									
								
							| @ -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, | ||||||
|  | |||||||
| @ -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 | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Aaron Liu
					Aaron Liu