Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: delete startup log file if empty

NTFSvolume36b51d2f3112
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index f0baf4843..8a3bc93ac 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -28,6 +28,7 @@ if TYPE_CHECKING:
from collections.abc import Callable
logger_startup = logging.getLogger("cyberdrop_dl_startup")
+LOGGER_STARTUP_FILE = Path().cwd().joinpath("downloader.log")
def startup() -> Manager:
@@ -107,11 +108,11 @@ async def post_runtime(manager: Manager) -> None:
def setup_startup_logger() -> None:
logger_startup.setLevel(10)
-
+ LOGGER_STARTUP_FILE.unlink(missing_ok=True)
rich_file_handler = RichHandler(
**constants.RICH_HANDLER_CONFIG,
console=RedactedConsole(
- file=Path().cwd().joinpath("downloader.log").open("w", encoding="utf8"),
+ file=LOGGER_STARTUP_FILE.open("w", encoding="utf8"),
width=constants.DEFAULT_CONSOLE_WIDTH,
),
level=10,
@@ -213,6 +214,9 @@ async def director(manager: Manager) -> None:
if manager.multiconfig:
configs_to_run = manager.config_manager.get_configs()
+ if LOGGER_STARTUP_FILE.is_file() and LOGGER_STARTUP_FILE.stat().st_size == 0:
+ LOGGER_STARTUP_FILE.unlink()
+
start_time = manager.start_time
while configs_to_run:
current_config = configs_to_run[0]