mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 04:12:42 +00:00
apt-sync: move_file_in handling src/file being dir
Related to "2543b0f apt-sync: fix deep pkgidx_file download error: no parent dir" In this commit, src/file can be some directory like .tmp/by-hash, when dst/by-hash is not empty dir, rename would fail. Not using replace() is suggested by @happyaron since this may behave oddly when the disk is full as this function is not atomic.
This commit is contained in:
parent
225d555544
commit
ef3a5bccac
@ -105,6 +105,10 @@ def move_files_in(src: Path, dst: Path):
|
||||
empty = False
|
||||
print(f"moving {file} to {dst}")
|
||||
# shutil.move(str(file), str(dst))
|
||||
if file.is_dir():
|
||||
(dst / file.name).mkdir(parents=True, exist_ok=True)
|
||||
move_files_in(file, dst / file.name)
|
||||
else:
|
||||
file.rename(dst / file.name) # Overwrite files
|
||||
if empty:
|
||||
print(f"{src} is empty")
|
||||
|
Loading…
x
Reference in New Issue
Block a user