Skip to content

Commit

Permalink
#8 优化文件上传功能
Browse files Browse the repository at this point in the history
  • Loading branch information
gowsp committed Dec 29, 2024
1 parent 5d3834e commit d33786c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/app/req_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strconv"

"github.com/gowsp/cloud189/pkg"
"github.com/gowsp/cloud189/pkg/file"
)

func (d *api) Search(parent pkg.File, fileType pkg.FileType, name string) ([]pkg.File, error) {
Expand Down Expand Up @@ -34,6 +35,9 @@ func (l *searchResult) fill(id string) (data []pkg.File) {
}

func (c *api) search(id, fileType, name string, page int) (result []pkg.File, err error) {
if file.IsSystem(id, name) {
return c.List(file.Root, pkg.DIR)
}
params := make(url.Values)
params.Set("folderId", id)
params.Set("filename", name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/req_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (a *api) signReq(url string) {
a.invoker.Refresh()
a.signReq(url)
default:
log.Printf("obtain: %s" + e.PrizeName)
log.Printf("obtain: %s", e.PrizeName)
}
} else {
log.Println(err)
Expand Down
5 changes: 3 additions & 2 deletions pkg/drive/drive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ func TestUpload(t *testing.T) {
api := app.New(invoker.DefaultPath())
fs := New(api)
cfg := pkg.UploadConfig{Num: 3}
fs.Upload(cfg, "/home", "D:/repo/go/src/github.com/gowsp/cloud189/docs/html")
fs.Upload(cfg, "/", "D:/tmp/01.txt")
// fs.Upload(cfg, "/home", "D:/repo/go/src/github.com/gowsp/cloud189/docs/html")
// fs.Upload(cfg, "/", "D:/tmp/01.txt")
fs.Upload(cfg, "/", "../")
// f, _ := os.Open("drive_test.go")
// l := file.NewLocalFile("-11", f)
// api.Uploader().Write(l)
Expand Down
3 changes: 2 additions & 1 deletion pkg/drive/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ func (client *FS) Upload(cfg pkg.UploadConfig, cloud string, locals ...string) e
if !cfg.Match(v.Name()) {
continue
}
r := v
task.Run(func() {
if err = uploader.Write(v); err != nil {
if err = uploader.Write(r); err != nil {
log.Println(err)
}
})
Expand Down

0 comments on commit d33786c

Please sign in to comment.