|
3 | 3 | from typing import List
|
4 | 4 |
|
5 | 5 | from xklb import usage
|
6 |
| -from xklb.utils import arg_utils, devices, objects, printing |
| 6 | +from xklb.utils import arg_utils, devices, file_utils, objects, printing |
7 | 7 | from xklb.utils.log_utils import log
|
8 | 8 |
|
9 | 9 |
|
@@ -70,25 +70,6 @@ def gen_rename_data(destination_folder, destination_files, source_folder, source
|
70 | 70 | return source_rename_data
|
71 | 71 |
|
72 | 72 |
|
73 |
| -def same_filesystem(path1, path2): |
74 |
| - stat1 = os.stat(path1) |
75 |
| - stat2 = os.stat(path2) |
76 |
| - return stat1.st_dev == stat2.st_dev |
77 |
| - |
78 |
| - |
79 |
| -def filter_valid_sources(args, destination_folder): |
80 |
| - valid_sources = [] |
81 |
| - for source in args.sources: |
82 |
| - if same_filesystem(source, destination_folder): |
83 |
| - valid_sources.append(source) |
84 |
| - else: |
85 |
| - print(f"Skipping {source}. Source not on same filesystem as destination.") |
86 |
| - |
87 |
| - if not valid_sources: |
88 |
| - print("No valid sources found. Sources and destination must be on the same filesystem.") |
89 |
| - raise SystemExit(1) |
90 |
| - |
91 |
| - return valid_sources |
92 | 73 |
|
93 | 74 |
|
94 | 75 | def get_clobber(args):
|
@@ -127,7 +108,10 @@ def mv(t):
|
127 | 108 | else:
|
128 | 109 | os.replace(t[1], t[2])
|
129 | 110 | else: ## file does not exist in destination already
|
130 |
| - os.renames(t[1], t[2]) |
| 111 | + try: |
| 112 | + os.renames(t[1], t[2]) |
| 113 | + except Exception: |
| 114 | + file_utils.rename_move_file(t[1], t[2]) |
131 | 115 |
|
132 | 116 | if args.simulate:
|
133 | 117 | for p in empty_folder_data:
|
@@ -162,7 +146,6 @@ def merge_folders() -> None:
|
162 | 146 | print("Destination:")
|
163 | 147 | destination_folder, destination_glob = args.destination
|
164 | 148 | destination_folder.mkdir(parents=True, exist_ok=True)
|
165 |
| - args.sources = filter_valid_sources(args, destination_folder) # TODO: add cross-fs support |
166 | 149 | destination_files, destination_folders_dict = existing_stats(destination_folder, destination_glob)
|
167 | 150 |
|
168 | 151 | destination_folders = (
|
|
0 commit comments