Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
refactor: vacuum requests database (#579)
NTFSvolume122d185c5e96
diff --git a/cyberdrop_dl/ui/program_ui.py b/cyberdrop_dl/ui/program_ui.pyindex 02f065744..5d86c7b94 100644--- a/cyberdrop_dl/ui/program_ui.py+++ b/cyberdrop_dl/ui/program_ui.py@@ -1,6 +1,7 @@from __future__ import annotationsimport asyncio+import sqlite3import sysfrom functools import wrapsfrom textwrap import dedent@@ -192,6 +193,12 @@ class ProgramUI:urls = user_prompts.filter_cache_urls(self.manager, domains)for url in urls:asyncio.run(self.manager.cache_manager.request_cache.delete_url(url))++ console.print("\nExecuting database vacuum. This may take several minutes, please wait...")+ try:+ vacuum_database(self.manager.path_manager.cache_db)+ except sqlite3.Error as e:+ return self.print_error(f"Unable to clean request database. Database may be corrupted : {e!s}")console.print("Finished clearing the cache", style="green")enter_to_continue()@@ -318,6 +325,19 @@ class ProgramUI:return "\n".join(lines[:4] + lines[6:])+def vacuum_database(db_path: Path) -> None:+ if not db_path.is_file():+ return+ try:+ conn = sqlite3.connect(db_path)+ cursor = conn.cursor()+ cursor.execute("VACUUM")+ conn.commit()+ finally:+ if conn:+ conn.close()++SIMPCITY_DISCLAIMER = """\t\t[bold red]!! DISCLAIMER !![/bold red]