diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2021-02-23 13:41:30 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-23 13:41:30 +0800 |
| commit | 620b91f23eaf5718088dc9ddcf91540967d0c8a6 (patch) | |
| tree | 04e92a8f92b548e26080040d009f23a51d9cc521 /weed/command/download.go | |
| parent | 690d7c10b826b53bf823faef76603cd6ad83aa1d (diff) | |
| parent | 90cdf9dcace5595b31104df3a3b7e4038a7db341 (diff) | |
| download | seaweedfs-620b91f23eaf5718088dc9ddcf91540967d0c8a6.tar.xz seaweedfs-620b91f23eaf5718088dc9ddcf91540967d0c8a6.zip | |
Merge pull request #73 from chrislusf/master
sync
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..7bbff9448 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 } |
