mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 09:35:00 +09:00
GO-1340: Add more logs, remove from uploading queue when adding to removing queue
This commit is contained in:
parent
5211e9329d
commit
e6aaf7e126
3 changed files with 17 additions and 5 deletions
|
@ -45,22 +45,32 @@ func (s *fileSyncStore) QueueDiscarded(spaceId, fileId string) (err error) {
|
|||
|
||||
func (s *fileSyncStore) QueueRemove(spaceId, fileId string) (err error) {
|
||||
return s.db.Update(func(txn *badger.Txn) error {
|
||||
if err = removeFromUploadingQueue(txn, spaceId, fileId); err != nil {
|
||||
return err
|
||||
}
|
||||
return txn.Set(removeKey(spaceId, fileId), binTime())
|
||||
})
|
||||
}
|
||||
|
||||
func (s *fileSyncStore) DoneUpload(spaceId, fileId string) (err error) {
|
||||
return s.db.Update(func(txn *badger.Txn) error {
|
||||
if err = txn.Delete(uploadKey(spaceId, fileId)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = txn.Delete(discardedKey(spaceId, fileId)); err != nil {
|
||||
if err = removeFromUploadingQueue(txn, spaceId, fileId); err != nil {
|
||||
return err
|
||||
}
|
||||
return txn.Set(doneKey(spaceId, fileId), binTime())
|
||||
})
|
||||
}
|
||||
|
||||
func removeFromUploadingQueue(txn *badger.Txn, spaceID string, fileID string) error {
|
||||
if err := txn.Delete(uploadKey(spaceID, fileID)); err != nil {
|
||||
return fmt.Errorf("remove from uploading queue: %w", err)
|
||||
}
|
||||
if err := txn.Delete(discardedKey(spaceID, fileID)); err != nil {
|
||||
return fmt.Errorf("remove from discarded uploading queue: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *fileSyncStore) DoneDiscarded(spaceId, fileId string) (err error) {
|
||||
return s.db.Update(func(txn *badger.Txn) error {
|
||||
if err = txn.Delete(discardedKey(spaceId, fileId)); err != nil {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func (f *fileSync) RemoveFile(spaceId, fileId string) (err error) {
|
||||
log.Info("add file to removing queue", zap.String("fileID", fileId))
|
||||
defer func() {
|
||||
if err == nil {
|
||||
select {
|
||||
|
@ -67,5 +68,6 @@ func (f *fileSync) tryToRemove() (string, error) {
|
|||
}
|
||||
|
||||
func (f *fileSync) removeFile(ctx context.Context, spaceId, fileId string) (err error) {
|
||||
log.Info("removing file", zap.String("fileID", fileId))
|
||||
return f.rpcStore.DeleteFiles(ctx, spaceId, fileId)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
func (f *fileSync) AddFile(spaceId, fileId string) (err error) {
|
||||
log.Info("add file to queue", zap.String("fileID", fileId))
|
||||
log.Info("add file to uploading queue", zap.String("fileID", fileId))
|
||||
defer func() {
|
||||
if err == nil {
|
||||
select {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue