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)
| 612 | // checkSrcMap is clear then it assumes that the any source files that |
| 613 | // have been found have been removed from dstFiles already. |
| 614 | func (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 |