feat(client/worker): support web work in frontend with fallback (#31)

* feat(client/web): add upload mgr

* feat(uploader): move uploader to worker

* feat(upload_mgr): use native worker for uploading

* fix(upload_mgr): fix uploading stop not working

* chore(client/web): cleanups

* test(upload.worker): add unit test for upload.worker

* feat(worker): add foreground upload worker

* chore(uploader): turn down the speedup
This commit is contained in:
Hexxa 2021-01-26 22:25:15 +08:00 committed by GitHub
parent 67c07cc81f
commit 31e4850344
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 1192 additions and 265 deletions

View file

@ -118,7 +118,11 @@ func (h *FileHandlers) Create(c *gin.Context) {
locker.Exec(func() {
err := h.deps.FS().Create(tmpFilePath)
if err != nil {
c.JSON(q.ErrResp(c, 500, err))
if os.IsExist(err) {
c.JSON(q.ErrResp(c, 304, err))
} else {
c.JSON(q.ErrResp(c, 500, err))
}
return
}
err = h.uploadMgr.AddInfo(userName, req.Path, tmpFilePath, req.FileSize)