[BUGFIX] Create persist log directory if it does not exist (#513)

This commit is contained in:
Jesse Bannon 2023-03-08 10:12:52 -08:00 committed by GitHub
parent 648027204f
commit fd1934b821
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import gc
import os
import sys
from datetime import datetime
from pathlib import Path
@ -54,6 +55,7 @@ def _maybe_write_subscription_log_file(
if not success:
Logger.log_exit_exception(exception=exception, log_filepath=persist_log_path)
os.makedirs(os.path.dirname(persist_log_path), exist_ok=True)
FileHandler.copy(Logger.debug_log_filename(), persist_log_path)

View file

@ -1,4 +1,6 @@
import os.path
import re
import shutil
import tempfile
import time
from pathlib import Path
@ -16,9 +18,15 @@ from ytdl_sub.utils.logger import Logger
@pytest.fixture
def persist_logs_directory():
def persist_logs_directory() -> str:
# Delete the temp_dir on creation
with tempfile.TemporaryDirectory() as temp_dir:
yield temp_dir
pass
yield temp_dir
if os.path.isdir(temp_dir):
shutil.rmtree(temp_dir)
@pytest.fixture