MCPcopy
hub / github.com/rclone/rclone / rollbackPendingUpload

Method rollbackPendingUpload

backend/cache/storage_persistent.go:890–916  ·  view source on GitHub ↗
(remote string)

Source from the content-addressed store, hash-verified

888}
889
890func (b *Persistent) rollbackPendingUpload(remote string) error {
891 b.tempQueueMux.Lock()
892 defer b.tempQueueMux.Unlock()
893
894 return b.db.Update(func(tx *bolt.Tx) error {
895 bucket, err := tx.CreateBucketIfNotExists([]byte(tempBucket))
896 if err != nil {
897 return fmt.Errorf("couldn't bucket for %v", tempBucket)
898 }
899 var tempObj = &tempUploadInfo{}
900 v := bucket.Get([]byte(remote))
901 err = json.Unmarshal(v, tempObj)
902 if err != nil {
903 return fmt.Errorf("pending upload (%v) not found: %w", remote, err)
904 }
905 tempObj.Started = false
906 v2, err := json.Marshal(tempObj)
907 if err != nil {
908 return fmt.Errorf("pending upload not updated: %w", err)
909 }
910 err = bucket.Put([]byte(tempObj.DestPath), v2)
911 if err != nil {
912 return fmt.Errorf("pending upload not updated: %w", err)
913 }
914 return nil
915 })
916}
917
918func (b *Persistent) removePendingUpload(remote string) error {
919 b.tempQueueMux.Lock()

Callers 1

runMethod · 0.80

Calls 6

LockMethod · 0.65
UnlockMethod · 0.65
UpdateMethod · 0.65
GetMethod · 0.65
PutMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected