diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-02-17 20:55:55 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-02-17 20:55:55 -0800 |
| commit | 6daa932f5c1571cc60cf89014cf17810d756dd6b (patch) | |
| tree | a6c6fce133c0178efec6324c708f3371dcd4f180 /weed/command/download.go | |
| parent | dd9f3a01049bef33046d3728d82b25b67b8533ac (diff) | |
| download | seaweedfs-6daa932f5c1571cc60cf89014cf17810d756dd6b.tar.xz seaweedfs-6daa932f5c1571cc60cf89014cf17810d756dd6b.zip | |
refactoring to get master function, instead of passing master values directly
this will enable retrying later
Diffstat (limited to 'weed/command/download.go')
| -rw-r--r-- | weed/command/download.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/weed/command/download.go b/weed/command/download.go index f7588fbf0..5da1f57d9 100644 --- a/weed/command/download.go +++ b/weed/command/download.go @@ -44,15 +44,15 @@ var cmdDownload = &Command{ func runDownload(cmd *Command, args []string) bool { for _, fid := range args { - if e := downloadToFile(*d.server, fid, util.ResolvePath(*d.dir)); e != nil { + if e := downloadToFile(func()string{return *d.server}, fid, util.ResolvePath(*d.dir)); e != nil { fmt.Println("Download Error: ", fid, e) } } return true } -func downloadToFile(server, fileId, saveDir string) error { - fileUrl, lookupError := operation.LookupFileId(server, fileId) +func downloadToFile(masterFn operation.GetMasterFn, fileId, saveDir string) error { + fileUrl, lookupError := operation.LookupFileId(masterFn, fileId) if lookupError != nil { return lookupError } @@ -83,7 +83,7 @@ func downloadToFile(server, fileId, saveDir string) error { fids := strings.Split(string(content), "\n") for _, partId := range fids { var n int - _, part, err := fetchContent(*d.server, partId) + _, part, err := fetchContent(masterFn, partId) if err == nil { n, err = f.Write(part) } @@ -103,8 +103,8 @@ func downloadToFile(server, fileId, saveDir string) error { return nil } -func fetchContent(server string, fileId string) (filename string, content []byte, e error) { - fileUrl, lookupError := operation.LookupFileId(server, fileId) +func fetchContent(masterFn operation.GetMasterFn, fileId string) (filename string, content []byte, e error) { + fileUrl, lookupError := operation.LookupFileId(masterFn, fileId) if lookupError != nil { return "", nil, lookupError } |
