diff --git a/commandes/bug_report.py b/commandes/bug_report.py index f4cadbc..9eacde9 100644 --- a/commandes/bug_report.py +++ b/commandes/bug_report.py @@ -12,9 +12,15 @@ from utils.premium import check_premium_tier kuby_logger = logging.getLogger("KubyBot") BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# ⚡ NOUVEAU: Utilise le même fichier que gitlab_integration.py -TRACKING_FILE = os.path.join(BASE_DIR, "commandes", "gitlab_issues.json") -LEGACY_REPORTS_FILE = os.path.join(BASE_DIR, "data", "gitlab_reports.json") +PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) +TRACKING_FILE = os.path.join(PROJECT_ROOT, "commandes", "gitlab_issues.json") +LEGACY_REPORTS_FILE = os.path.join(PROJECT_ROOT, "data", "gitlab_reports.json") + +# S'assure que le fichier de tracking est toujours écrit à l'emplacement attendu même si le service systemd démarre depuis un autre répertoire. +if not os.path.exists(TRACKING_FILE): + legacy_candidate = os.path.join(BASE_DIR, "commandes", "gitlab_issues.json") + if os.path.exists(legacy_candidate): + TRACKING_FILE = legacy_candidate def classify_webhook_event(payload: Dict[str, Any]) -> Optional[str]: