mirror of
https://github.com/taoky/shadowmire.git
synced 2025-07-08 09:12:43 +00:00
Add clear-invalid-packages command
This commit is contained in:
parent
354bfaf28e
commit
b73dca7688
@ -117,6 +117,13 @@ class LocalVersionKV:
|
||||
cur.execute("DELETE FROM local WHERE key = ?", (key,))
|
||||
self.conn.commit()
|
||||
|
||||
def remove_invalid(self) -> int:
|
||||
cur = self.conn.cursor()
|
||||
cur.execute("DELETE FROM local WHERE value = -1")
|
||||
rowcnt = cur.rowcount
|
||||
self.conn.commit()
|
||||
return rowcnt
|
||||
|
||||
def nuke(self, commit: bool = True) -> None:
|
||||
cur = self.conn.cursor()
|
||||
cur.execute("DELETE FROM local")
|
||||
@ -1476,5 +1483,13 @@ def list_packages_with_serial(ctx: click.Context) -> None:
|
||||
syncer.fetch_remote_versions()
|
||||
|
||||
|
||||
@cli.command(help="Clear invalid package status in local database")
|
||||
@click.pass_context
|
||||
def clear_invalid_packages(ctx: click.Context) -> None:
|
||||
local_db: LocalVersionKV = ctx.obj["local_db"]
|
||||
total = local_db.remove_invalid()
|
||||
logger.info("Removed %s invalid status in local database", total)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli(obj={})
|
||||
|
Loading…
x
Reference in New Issue
Block a user