MCPcopy
hub / github.com/rclone/rclone / Remove

Method Remove

backend/cache/object.go:288–315  ·  view source on GitHub ↗

Remove deletes the object from both the cache and the source

(ctx context.Context)

Source from the content-addressed store, hash-verified

286
287// Remove deletes the object from both the cache and the source
288func (o *Object) Remove(ctx context.Context) error {
289 if err := o.refreshFromSource(ctx, false); err != nil {
290 return err
291 }
292 // pause background uploads if active
293 if o.CacheFs.opt.TempWritePath != "" {
294 o.CacheFs.backgroundRunner.pause()
295 defer o.CacheFs.backgroundRunner.play()
296 // don't allow started uploads
297 if o.isTempFile() && o.tempFileStartedUpload() {
298 return fmt.Errorf("%v is currently uploading, can't delete", o)
299 }
300 }
301 err := o.Object.Remove(ctx)
302 if err != nil {
303 return err
304 }
305
306 fs.Debugf(o, "removing object")
307 _ = o.CacheFs.cache.RemoveObject(o.abs())
308 _ = o.CacheFs.cache.removePendingUpload(o.abs())
309 parentCd := NewDirectory(o.CacheFs, cleanPath(path.Dir(o.Remote())))
310 _ = o.CacheFs.cache.ExpireDir(parentCd)
311 // advertise to ChangeNotify if wrapped doesn't do that
312 o.CacheFs.notifyChangeUpstreamIfNeeded(parentCd.Remote(), fs.EntryDirectory)
313
314 return nil
315}
316
317// Hash requests a hash of the object and stores in the cache
318// since it might or might not be called, this is lazy loaded

Callers 1

rmMethod · 0.95

Calls 15

refreshFromSourceMethod · 0.95
isTempFileMethod · 0.95
tempFileStartedUploadMethod · 0.95
absMethod · 0.95
RemoteMethod · 0.95
RemoteMethod · 0.95
DebugfFunction · 0.92
cleanPathFunction · 0.85
pauseMethod · 0.80
playMethod · 0.80
RemoveObjectMethod · 0.80
removePendingUploadMethod · 0.80

Tested by 1

rmMethod · 0.76