MCPcopy
hub / github.com/rclone/rclone / httpExpireRemote

Method httpExpireRemote

backend/cache/cache.go:638–681  ·  view source on GitHub ↗
(ctx context.Context, in rc.Params)

Source from the content-addressed store, hash-verified

636}
637
638func (f *Fs) httpExpireRemote(ctx context.Context, in rc.Params) (out rc.Params, err error) {
639 out = make(rc.Params)
640 remoteInt, ok := in["remote"]
641 if !ok {
642 return out, fmt.Errorf("remote is needed")
643 }
644 remote := remoteInt.(string)
645 withData := false
646 _, ok = in["withData"]
647 if ok {
648 withData = true
649 }
650
651 remote = f.unwrapRemote(remote)
652 if !f.cache.HasEntry(path.Join(f.Root(), remote)) {
653 return out, fmt.Errorf("%s doesn't exist in cache", remote)
654 }
655
656 co := NewObject(f, remote)
657 err = f.cache.GetObject(co)
658 if err != nil { // it could be a dir
659 cd := NewDirectory(f, remote)
660 err := f.cache.ExpireDir(cd)
661 if err != nil {
662 return out, fmt.Errorf("error expiring directory: %w", err)
663 }
664 // notify vfs too
665 f.notifyChangeUpstream(cd.Remote(), fs.EntryDirectory)
666 out["status"] = "ok"
667 out["message"] = fmt.Sprintf("cached directory cleared: %v", remote)
668 return out, nil
669 }
670 // expire the entry
671 err = f.cache.ExpireObject(co, withData)
672 if err != nil {
673 return out, fmt.Errorf("error expiring file: %w", err)
674 }
675 // notify vfs too
676 f.notifyChangeUpstream(co.Remote(), fs.EntryObject)
677
678 out["status"] = "ok"
679 out["message"] = fmt.Sprintf("cached file cleared: %v", remote)
680 return out, nil
681}
682
683func (f *Fs) rcFetch(ctx context.Context, in rc.Params) (rc.Params, error) {
684 type chunkRange struct {

Callers

nothing calls this directly

Calls 13

unwrapRemoteMethod · 0.95
RootMethod · 0.95
notifyChangeUpstreamMethod · 0.95
RemoteMethod · 0.95
RemoteMethod · 0.95
HasEntryMethod · 0.80
JoinMethod · 0.80
ExpireDirMethod · 0.80
ExpireObjectMethod · 0.80
NewObjectFunction · 0.70
NewDirectoryFunction · 0.70
ErrorfMethod · 0.45

Tested by

no test coverage detected