[BUGFIX] Create persist log directory if it does not exist (#513)
This commit is contained in:
parent
648027204f
commit
fd1934b821
2 changed files with 12 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import gc
|
import gc
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
@ -54,6 +55,7 @@ def _maybe_write_subscription_log_file(
|
||||||
if not success:
|
if not success:
|
||||||
Logger.log_exit_exception(exception=exception, log_filepath=persist_log_path)
|
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)
|
FileHandler.copy(Logger.debug_log_filename(), persist_log_path)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
@ -16,9 +18,15 @@ from ytdl_sub.utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def persist_logs_directory():
|
def persist_logs_directory() -> str:
|
||||||
|
# Delete the temp_dir on creation
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
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
|
@pytest.fixture
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue