MCPcopy
hub / github.com/rclone/rclone / searchPendingUploadFromDir

Method searchPendingUploadFromDir

backend/cache/storage_persistent.go:863–888  ·  view source on GitHub ↗

searchPendingUploadFromDir files currently pending upload from a single dir

(dir string)

Source from the content-addressed store, hash-verified

861
862// searchPendingUploadFromDir files currently pending upload from a single dir
863func (b *Persistent) searchPendingUploadFromDir(dir string) (remotes []string, err error) {
864 err = b.db.View(func(tx *bolt.Tx) error {
865 bucket := tx.Bucket([]byte(tempBucket))
866 if bucket == nil {
867 return fmt.Errorf("couldn't bucket for %v", tempBucket)
868 }
869
870 c := bucket.Cursor()
871 for k, v := c.First(); k != nil; k, v = c.Next() {
872 var tempObj = &tempUploadInfo{}
873 err = json.Unmarshal(v, tempObj)
874 if err != nil {
875 fs.Errorf(b, "failed to read pending upload: %v", err)
876 continue
877 }
878 parentDir := cleanPath(path.Dir(tempObj.DestPath))
879 if dir == parentDir {
880 remotes = append(remotes, tempObj.DestPath)
881 }
882 }
883
884 return nil
885 })
886
887 return remotes, err
888}
889
890func (b *Persistent) rollbackPendingUpload(remote string) error {
891 b.tempQueueMux.Lock()

Callers 1

ListMethod · 0.80

Calls 7

ErrorfFunction · 0.92
cleanPathFunction · 0.85
FirstMethod · 0.80
DirMethod · 0.80
CursorMethod · 0.65
NextMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected