示例#1
0
    def _check_case_insensitive_sources_destinations(self):
        key_getter = lambda path: ([component.lower() for component in path.components], path)

        source_paths = sets_union([f.old_file_ref.path.subpaths(exclude_root=True) for f in self.renamed_files])
        for path_a, path_b in pairwise(sorted(source_paths, key=key_getter)):
            if path_a.equals_ignore_case(path_b):
                raise CaseInsensitiveConflictInSourcePathsError(path_a.path_text(), path_b.path_text())

        destination_paths = sets_union([f.path.subpaths(exclude_root=True) for f in self.renamed_files])
        for path_a, path_b in pairwise(sorted(destination_paths, key=key_getter)):
            if path_a.equals_ignore_case(path_b):
                raise CaseInsensitiveConflictInDestinationPathsError(path_a.path_text(), path_b.path_text())
示例#2
0
    def _phase3_delete_emptied_directories(self):
        source_parent_paths = sets_union(
            f.old_file_ref.path.subpaths(exclude_root=True, exclude_self=True) for f in self.renamed_files
        )

        undeletable_dirs = set()

        for path in reversed(sorted(source_parent_paths)):
            if path in undeletable_dirs:
                continue

            files_in_dir = set(self._list_dir(path.real_path()))
            if path in self.removed_entries_by_path:
                files_in_dir -= self.removed_entries_by_path[path]

            if len(files_in_dir) == 0 and check_file_rights(
                path.parent_path().real_path(), read=True, write=True, execute=True
            ):
                self.steps.append(DeleteEmptyDirectoryAction(path.real_path()))
                self.removed_entries_by_path[path.parent_path()].add(path.basename())
            else:
                undeletable_dirs |= set(path.subpaths(exclude_root=True, exclude_self=True))
示例#3
0
    def _phase1_create_staging_structure(self):
        self.destination_dirs = sorted(sets_union(f.path.parent_paths() for f in self.renamed_files))
        self.staging_structure = sorted(self._path_to_staging_dir(path) for path in self.destination_dirs)

        self.steps.extend(CreateDirectoryAction(path.real_path()) for path in self.staging_structure)