mirror of
https://github.com/taoky/shadowmire.git
synced 2025-07-08 17:32:43 +00:00
Defer package removal in verify
This commit is contained in:
parent
6102de1bf7
commit
dad48fc8a9
@ -89,7 +89,7 @@ Verify command could be used if you believe that something is wrong (inconsisten
|
|||||||
./shadowmire.py verify --sync-packages
|
./shadowmire.py verify --sync-packages
|
||||||
```
|
```
|
||||||
|
|
||||||
Verify command accepts same arguments as sync.
|
Verify command accepts same arguments as sync, and accepts some new arguments. Please check `./shadowmire.py verify --help` for more information.
|
||||||
|
|
||||||
If you don't like appending a long argument list, you could use `--config` ([example](./config.example.toml)):
|
If you don't like appending a long argument list, you could use `--config` ([example](./config.example.toml)):
|
||||||
|
|
||||||
|
@ -570,14 +570,16 @@ class SyncBase:
|
|||||||
|
|
||||||
self.parallel_update(to_update, prerelease_excludes)
|
self.parallel_update(to_update, prerelease_excludes)
|
||||||
|
|
||||||
def do_remove(self, package_name: str, use_db: bool = True) -> None:
|
def do_remove(
|
||||||
|
self, package_name: str, use_db: bool = True, remove_packages: bool = True
|
||||||
|
) -> None:
|
||||||
metajson_path = self.jsonmeta_dir / package_name
|
metajson_path = self.jsonmeta_dir / package_name
|
||||||
if metajson_path.exists():
|
if metajson_path.exists():
|
||||||
# To make this less noisy...
|
# To make this less noisy...
|
||||||
logger.info("removing %s", package_name)
|
logger.info("removing %s", package_name)
|
||||||
package_simple_dir = self.simple_dir / package_name
|
package_simple_dir = self.simple_dir / package_name
|
||||||
packages_to_remove = get_existing_hrefs(package_simple_dir)
|
packages_to_remove = get_existing_hrefs(package_simple_dir)
|
||||||
if packages_to_remove:
|
if remove_packages and packages_to_remove:
|
||||||
paths_to_remove = [package_simple_dir / p for p in packages_to_remove]
|
paths_to_remove = [package_simple_dir / p for p in packages_to_remove]
|
||||||
for p in paths_to_remove:
|
for p in paths_to_remove:
|
||||||
if p.exists():
|
if p.exists():
|
||||||
@ -1008,7 +1010,9 @@ def genlocal(ctx: click.Context) -> None:
|
|||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@sync_shared_args
|
@sync_shared_args
|
||||||
@click.option("--remove-not-in-local", is_flag=True, help="Do step 1 instead of skipping")
|
@click.option(
|
||||||
|
"--remove-not-in-local", is_flag=True, help="Do step 1 instead of skipping"
|
||||||
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--compare-size",
|
"--compare-size",
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
@ -1037,7 +1041,12 @@ def verify(
|
|||||||
for package_name in not_in_local:
|
for package_name in not_in_local:
|
||||||
logger.debug("package %s not in local db", package_name)
|
logger.debug("package %s not in local db", package_name)
|
||||||
if remove_not_in_local:
|
if remove_not_in_local:
|
||||||
syncer.do_remove(package_name)
|
# Old bandersnatch would download packages without normalization,
|
||||||
|
# in which case one package file could have multiple "packages"
|
||||||
|
# with different names, but normalized to the same one.
|
||||||
|
# So, when in verify, we always set remove_packages=False
|
||||||
|
# In step 4 unreferenced files would be removed, anyway.
|
||||||
|
syncer.do_remove(package_name, remove_packages=False)
|
||||||
|
|
||||||
logger.info("remove packages NOT in remote")
|
logger.info("remove packages NOT in remote")
|
||||||
local = local_db.dump(skip_invalid=False)
|
local = local_db.dump(skip_invalid=False)
|
||||||
@ -1046,7 +1055,7 @@ def verify(
|
|||||||
for package_name in plan.remove:
|
for package_name in plan.remove:
|
||||||
# We only take the plan.remove part here
|
# We only take the plan.remove part here
|
||||||
logger.debug("package %s not in remote index", package_name)
|
logger.debug("package %s not in remote index", package_name)
|
||||||
syncer.do_remove(package_name)
|
syncer.do_remove(package_name, remove_packages=False)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"make sure all local indexes are valid, and (if --sync-packages) have valid local package files"
|
"make sure all local indexes are valid, and (if --sync-packages) have valid local package files"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user