From b349f2abd3e2e1d9c05bc90255fdc537e28fbcf5 Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Mar 04 2024 14:47:08 +0000
Subject: Fix temporary cg_import.log file path


Related: https://pagure.io/koji/issue/4036

---

diff --git a/kojihub/kojihub.py b/kojihub/kojihub.py
index 1c75a09..c39389c 100644
--- a/kojihub/kojihub.py
+++ b/kojihub/kojihub.py
@@ -7012,10 +7012,11 @@ class CG_Importer(object):
 
     def log(self, msg, level=logging.WARNING):
         if self._cg_log_file is None:
-            log_dir = joinpath(koji.pathinfo.work(), 'logs')
+            log_dir = joinpath(koji.pathinfo.work(), 'cg_import_logs')
             koji.ensuredir(log_dir)
-            self._cg_log_path = joinpath(log_dir, 'cg_import.log')
-            self._cg_log_file = open(self._cg_log_path, mode='wt')
+            fd, fpath = tempfile.mkstemp(dir=log_dir, suffix="-cg_import.log", text=True)
+            self._cg_log_path = fpath
+            self._cg_log_file = os.fdopen(fd, 'wt')
         logger.log(level=level, msg=msg)
         self._cg_log_file.write(msg + '\n')
         self._cg_log_file.flush()

