require an argument for --clear-cache

pull/1633/head
Mike Fährmann 3 years ago
parent a751afdfb3
commit 40eb8025cc
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -168,7 +168,7 @@ def cache(maxage=3600, keyarg=None):
return wrap
def clear(module="all"):
def clear(module):
"""Delete database entries for 'module'"""
db = DatabaseCacheDecorator.db
if not db:
@ -176,19 +176,18 @@ def clear(module="all"):
rowcount = 0
cursor = db.cursor()
module = module.lower()
try:
if module == "all":
if module == "ALL":
cursor.execute("DELETE FROM data")
else:
cursor.execute(
"DELETE FROM data "
"WHERE key LIKE 'gallery_dl.extractor.' || ? || '.%'",
(module,)
(module.lower(),)
)
except sqlite3.OperationalError:
pass # database is not initialized, can't be modified, etc.
pass # database not initialized, cannot be modified, etc.
else:
rowcount = cursor.rowcount
db.commit()

@ -114,8 +114,9 @@ def build_parser():
)
general.add_argument(
"--clear-cache",
dest="clear_cache", metavar="MODULE", nargs="?", const="all",
help="Delete all cached login sessions, cookies, etc.",
dest="clear_cache", metavar="MODULE",
help="Delete cached login sessions, cookies, etc. for MODULE "
"(ALL to delete everything)",
)
output = parser.add_argument_group("Output Options")

Loading…
Cancel
Save