NewObject builds one from a generic fs.Object
(f *Fs, remote string)
| 41 | |
| 42 | // NewObject builds one from a generic fs.Object |
| 43 | func NewObject(f *Fs, remote string) *Object { |
| 44 | fullRemote := path.Join(f.Root(), remote) |
| 45 | dir, name := path.Split(fullRemote) |
| 46 | |
| 47 | cacheType := objectInCache |
| 48 | parentFs := f.UnWrap() |
| 49 | if f.opt.TempWritePath != "" { |
| 50 | _, err := f.cache.SearchPendingUpload(fullRemote) |
| 51 | if err == nil { // queued for upload |
| 52 | cacheType = objectPendingUpload |
| 53 | parentFs = f.tempFs |
| 54 | fs.Debugf(fullRemote, "pending upload found") |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | co := &Object{ |
| 59 | ParentFs: parentFs, |
| 60 | CacheFs: f, |
| 61 | Name: cleanPath(name), |
| 62 | Dir: cleanPath(dir), |
| 63 | CacheModTime: time.Now().UnixNano(), |
| 64 | CacheSize: 0, |
| 65 | CacheStorable: false, |
| 66 | CacheType: cacheType, |
| 67 | CacheTs: time.Now(), |
| 68 | } |
| 69 | return co |
| 70 | } |
| 71 | |
| 72 | // ObjectFromOriginal builds one from a generic fs.Object |
| 73 | func ObjectFromOriginal(ctx context.Context, f *Fs, o fs.Object) *Object { |
no test coverage detected
searching dependent graphs…