MCPcopy Index your code
hub / github.com/rclone/rclone / deleteFiles

Method deleteFiles

fs/sync/sync.go:614–653  ·  view source on GitHub ↗

This deletes the files in the dstFiles map. If checkSrcMap is set then it checks to see if they exist first in srcFiles the source file map, otherwise it unconditionally deletes them. If checkSrcMap is clear then it assumes that the any source files that have been found have been removed from dstF

(checkSrcMap bool)

Source from the content-addressed store, hash-verified

612// checkSrcMap is clear then it assumes that the any source files that
613// have been found have been removed from dstFiles already.
614func (s *syncCopyMove) deleteFiles(checkSrcMap bool) error {
615 if accounting.Stats(s.ctx).Errored() && !s.ci.IgnoreErrors {
616 fs.Errorf(s.fdst, "%v", fs.ErrorNotDeleting)
617 // log all deletes as errors
618 for remote, o := range s.dstFiles {
619 if checkSrcMap {
620 _, exists := s.srcFiles[remote]
621 if exists {
622 continue
623 }
624 }
625 s.logger(s.ctx, operations.TransferError, nil, o, fs.ErrorNotDeleting)
626 }
627 return fs.ErrorNotDeleting
628 }
629
630 // Delete the spare files
631 toDelete := make(fs.ObjectsChan, s.ci.Checkers)
632 go func() {
633 outer:
634 for remote, o := range s.dstFiles {
635 if checkSrcMap {
636 _, exists := s.srcFiles[remote]
637 if exists {
638 continue
639 }
640 }
641 if s.aborting() {
642 break
643 }
644 select {
645 case <-s.ctx.Done():
646 break outer
647 case toDelete <- o:
648 }
649 }
650 close(toDelete)
651 }()
652 return operations.DeleteFilesWithBackupDir(s.ctx, toDelete, s.backupDir)
653}
654
655// This deletes the empty directories in the slice passed in. It
656// ignores any errors deleting directories

Callers 1

runMethod · 0.95

Calls 7

abortingMethod · 0.95
StatsFunction · 0.92
ErrorfFunction · 0.92
DeleteFilesWithBackupDirFunction · 0.92
closeFunction · 0.85
ErroredMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected