| 888 | } |
| 889 | |
| 890 | func (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 | |
| 918 | func (b *Persistent) removePendingUpload(remote string) error { |
| 919 | b.tempQueueMux.Lock() |