Fix log file path issue for support log/log delete

This commit is contained in:
amcmanu3 2022-07-18 14:55:12 -04:00
parent b69cdd757e
commit f265b070c0
2 changed files with 13 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import os
import logging
import time
import json
import pathlib
import typing as t
from app.classes.controllers.roles_controller import RolesController
@ -538,7 +539,14 @@ class ServersController(metaclass=Singleton):
continue
log_files = list(
filter(lambda val: val != latest_log_file, os.listdir(logs_path))
filter(
lambda val: val != latest_log_file,
os.listdir(
pathlib.Path(
server["path"], os.path.split(server["log_path"])[0]
)
),
)
)
for log_file in log_files:
log_file_path = os.path.join(logs_path, log_file)

View File

@ -159,7 +159,10 @@ class Controller:
final_path += "_" + server["server_uuid"]
os.mkdir(final_path)
try:
FileHelpers.copy_file(server["log_path"], final_path)
FileHelpers.copy_file(
pathlib.Path(server["path"], server["log_path"]),
final_path,
)
except Exception as e:
logger.warning(f"Failed to copy file with error: {e}")
# Copy crafty logs to archive dir