Skip to content

Commit

Permalink
Move-to-archive: ignore the codecs category
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Jul 31, 2024
1 parent a001576 commit 967349b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions mirrormanager2/utility/move_to_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
from .common import config_option

DEFAULT_ARCHIVE_CATEGORY = "Fedora Archive"
IGNORE_CATEGORIES = ["Fedora Codecs"]
SKIP_DIR_PREFIX = "pub/"


def doit(session, product, version, archive_cat):
def doit(session, product, version, archive_cat, dry_run):
archivetopdir = archive_cat.topdir.name
repos = mirrormanager2.lib.get_repositories(session, product_name=product, version_name=version)
for repo in repos:
Expand All @@ -27,6 +28,12 @@ def doit(session, product, version, archive_cat):
if repo.category == archive_cat:
click.echo(f"Repo {repo.name} (prefix {repo.prefix}) is already archived, skipping.")
continue
if repo.category.name in IGNORE_CATEGORIES:
click.echo(
f"Repo {repo.name} (prefix {repo.prefix}) is in the "
f"{repo.category.name!r} category, skipping."
)
continue

subdir = repo.directory.name
if subdir.startswith(SKIP_DIR_PREFIX):
Expand All @@ -40,8 +47,9 @@ def doit(session, product, version, archive_cat):
click.echo(f"{repo.directory.name} => {target_dir}")
repo.directory = new_d
repo.category = archive_cat
session.add(repo)
session.commit()
if not dry_run:
session.add(repo)
session.commit()


@click.command()
Expand All @@ -63,7 +71,13 @@ def doit(session, product, version, archive_cat):
default=DEFAULT_ARCHIVE_CATEGORY,
show_default=1,
)
def main(config, archive_category, product, version):
@click.option(
"--dry-run",
help="Only show what would be done, don't commit to the database",
is_flag=True,
default=False,
)
def main(config, product, version, archive_category, dry_run):
d = mirrormanager2.lib.read_config(config)
db_manager = get_db_manager(d)
session = db_manager.Session()
Expand All @@ -76,4 +90,4 @@ def main(config, archive_category, product, version):
raise click.BadOptionUsage(
"--archive-category", f"No category could be found by the name: {archive_category}"
)
doit(session, product, version, archive_cat)
doit(session, product, version, archive_cat, dry_run)

0 comments on commit 967349b

Please sign in to comment.