mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-11 02:13:41 +09:00
GO-1340: Remove deleted file from uploading queue
This commit is contained in:
parent
7dd66c795a
commit
5211e9329d
2 changed files with 10 additions and 9 deletions
|
@ -521,8 +521,8 @@ func (dp *dropFilesProcess) addFilesWorker(wg *sync.WaitGroup, in chan *dropFile
|
|||
func (dp *dropFilesProcess) addFile(f *dropFileInfo) (err error) {
|
||||
upl := NewUploader(dp.s, dp.fileService, dp.tempDirProvider)
|
||||
res := upl.SetName(f.name).AutoType(true).SetFile(f.path).Upload(context.TODO())
|
||||
log.With("filePath", f.path).Error("upload error: %s", res.Err)
|
||||
if res.Err != nil {
|
||||
log.With("filePath", f.path).Errorf("upload error: %s", res.Err)
|
||||
f.err = fmt.Errorf("upload error: %w", res.Err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -72,6 +72,15 @@ func (f *fileSync) tryToUpload() (string, error) {
|
|||
return fileId, err
|
||||
}
|
||||
if err = f.uploadFile(f.loopCtx, spaceId, fileId); err != nil {
|
||||
ok, storeErr := f.hasFileInStore(fileId)
|
||||
if storeErr != nil {
|
||||
return fileId, storeErr
|
||||
}
|
||||
if !ok {
|
||||
log.Warn("file has been deleted from store, skip upload", zap.String("fileId", fileId))
|
||||
return fileId, f.queue.DoneUpload(spaceId, fileId)
|
||||
}
|
||||
|
||||
if err == errReachedLimit {
|
||||
if !wasDiscarded {
|
||||
f.sendLimitReachedEvent(spaceId, fileId)
|
||||
|
@ -83,14 +92,6 @@ func (f *fileSync) tryToUpload() (string, error) {
|
|||
return fileId, err
|
||||
}
|
||||
|
||||
ok, storeErr := f.hasFileInStore(fileId)
|
||||
if storeErr != nil {
|
||||
return fileId, storeErr
|
||||
}
|
||||
if !ok {
|
||||
log.Warn("file has been deleted from store, skip upload", zap.String("fileId", fileId))
|
||||
return fileId, f.queue.DoneUpload(spaceId, fileId)
|
||||
}
|
||||
// Push to the back of the queue
|
||||
if qerr := f.queue.QueueUpload(spaceId, fileId); qerr != nil {
|
||||
log.Warn("can't push upload task back to queue", zap.String("fileId", fileId), zap.Error(qerr))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue