mirror of
https://github.com/taoky/shadowmire.git
synced 2025-07-08 09:12:43 +00:00
Remove invalid local ones when planning
This commit is contained in:
parent
9008d2cbce
commit
649d14c4fd
@ -146,6 +146,8 @@ def remove_dir_with_files(directory: Path) -> None:
|
||||
"""
|
||||
Remove dir in a safer (non-recursive) way, which means that the directory should have no child directories.
|
||||
"""
|
||||
if not directory.exists():
|
||||
return
|
||||
assert directory.is_dir()
|
||||
for item in directory.iterdir():
|
||||
item.unlink()
|
||||
@ -407,6 +409,7 @@ class SyncBase:
|
||||
if local_serial != remote_serial:
|
||||
if local_serial == -1:
|
||||
logger.info("skip %s, as it's marked as not exist at upstream", i)
|
||||
to_remove.append(i)
|
||||
else:
|
||||
to_update.append(i)
|
||||
output = Plan(remove=to_remove, update=to_update)
|
||||
@ -474,11 +477,12 @@ class SyncBase:
|
||||
logger.info("Removed file %s", p_path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
# remove all files inside meta_dir
|
||||
self.local_db.remove(package_name)
|
||||
remove_dir_with_files(meta_dir)
|
||||
except FileNotFoundError:
|
||||
logger.warning("FileNotFoundError when removing %s", package_name)
|
||||
pass
|
||||
|
||||
def do_update(
|
||||
self,
|
||||
|
Loading…
x
Reference in New Issue
Block a user