searchPendingUploadFromDir files currently pending upload from a single dir
(dir string)
| 861 | |
| 862 | // searchPendingUploadFromDir files currently pending upload from a single dir |
| 863 | func (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 | |
| 890 | func (b *Persistent) rollbackPendingUpload(remote string) error { |
| 891 | b.tempQueueMux.Lock() |