mark the parent of entry as not empty and if entry is a directory mark it as potentially empty.
(entry fs.DirEntry)
| 698 | |
| 699 | // mark the parent of entry as not empty and if entry is a directory mark it as potentially empty. |
| 700 | func (s *syncCopyMove) markParentNotEmpty(entry fs.DirEntry) { |
| 701 | s.srcEmptyDirsMu.Lock() |
| 702 | defer s.srcEmptyDirsMu.Unlock() |
| 703 | // Mark entry as potentially empty if it is a directory |
| 704 | _, isDir := entry.(fs.Directory) |
| 705 | if isDir { |
| 706 | s.srcEmptyDirs[entry.Remote()] = entry |
| 707 | // if DoMove and --delete-empty-src-dirs flag is set then record the parent but |
| 708 | // don't remove any as we are about to move files out of them them making the |
| 709 | // directory empty. |
| 710 | if s.DoMove && s.deleteEmptySrcDirs { |
| 711 | s.srcMoveEmptyDirs[entry.Remote()] = entry |
| 712 | } |
| 713 | } |
| 714 | parentDir := path.Dir(entry.Remote()) |
| 715 | if isDir && s.copyEmptySrcDirs { |
| 716 | // Mark its parent as not empty |
| 717 | if parentDir == "." { |
| 718 | parentDir = "" |
| 719 | } |
| 720 | delete(s.srcEmptyDirs, parentDir) |
| 721 | } |
| 722 | if !isDir { |
| 723 | // Mark ALL its parents as not empty |
| 724 | for { |
| 725 | if parentDir == "." { |
| 726 | parentDir = "" |
| 727 | } |
| 728 | delete(s.srcEmptyDirs, parentDir) |
| 729 | if parentDir == "" || parentDir == "/" { |
| 730 | break |
| 731 | } |
| 732 | parentDir = path.Dir(parentDir) |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | // parseTrackRenamesStrategy turns a config string into a trackRenamesStrategy |
| 738 | func parseTrackRenamesStrategy(strategies string) (strategy trackRenamesStrategy, err error) { |