diff --git a/apis/public/bitsend/download.go b/apis/public/bitsend/download.go index 610c4af..fbb6bdc 100644 --- a/apis/public/bitsend/download.go +++ b/apis/public/bitsend/download.go @@ -27,7 +27,7 @@ func (b bitSend) DoDownload(link string, config apis.DownConfig) error { func (b bitSend) download(v string, config apis.DownConfig) error { var link string - if config.DebugMode { + if apis.DebugMode { log.Printf("fetching: %v", v) } fmt.Printf("fetching ticket..") @@ -45,18 +45,17 @@ func (b bitSend) download(v string, config apis.DownConfig) error { } _ = resp.Body.Close() link = "https://bitsend.jp/" + regex.FindString(string(body)) - if config.DebugMode { + if apis.DebugMode { log.Printf("dest: %v", link) } b.Ticket = resp.Header.Get("Set-Cookie") *end <- struct{}{} fmt.Printf("ok\n") - return apis.DownloadFile(&apis.DownloaderConfig{ - Link: link, - Config: config, - Modifier: b.addRef(v), - }) + config.Link = link + config.Modifier = b.addRef(v) + + return apis.DownloadFile(config) } func (b bitSend) addRef(ref string) func(req *http.Request) { diff --git a/apis/public/musetransfer/api.go b/apis/public/musetransfer/api.go index a139918..01c9ff8 100644 --- a/apis/public/musetransfer/api.go +++ b/apis/public/musetransfer/api.go @@ -18,7 +18,7 @@ type muse struct { apis.Backend Config museOptions - EtagMap sync.Map + EtagMap *sync.Map Assets []int64 Commands [][]string } diff --git a/apis/public/musetransfer/upload.go b/apis/public/musetransfer/upload.go index e6d287b..72e3ddc 100644 --- a/apis/public/musetransfer/upload.go +++ b/apis/public/musetransfer/upload.go @@ -68,6 +68,7 @@ func (b *muse) getUploadToken() (*s3Token, error) { } func (b *muse) newTransfer() error { + b.EtagMap = new(sync.Map) fmt.Printf("fetching upload tickets..") end := utils.DotTicker() @@ -245,9 +246,6 @@ func (b *muse) DoUpload(name string, size int64, file io.Reader) error { return err } b.ossSigner(req, auth) - if apis.DebugMode { - log.Println("usq header: ", req.Header) - } http.DefaultClient.Timeout = time.Duration(b.Config.interval) * time.Second resp, err = http.DefaultClient.Do(req) if err != nil { @@ -261,8 +259,8 @@ func (b *muse) DoUpload(name string, size int64, file io.Reader) error { func (b *muse) generate_payload(max int64) string { var payload string - payload = `` - payload += "" + payload = "\n" + payload += "\n" for i := int64(1); i <= max; i++ { if v, ok := b.EtagMap.LoadAndDelete(i); ok { payload += fmt.Sprintf("%d%s", i, v)