mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-13 14:29:42 +08:00
MockModuleBuilder: don't accidentally remove log files from other threads
The _purge_useless_log_files() method, if run at the wrong time, would remove log files that other threads were still creating.
This commit is contained in:
@@ -608,11 +608,15 @@ class MockModuleBuilder(GenericBuilder):
|
||||
if os.path.exists(old_log):
|
||||
os.rename(old_log, new_log)
|
||||
|
||||
def _purge_useless_logs(self):
|
||||
def _purge_useless_logs(self, artifact_name):
|
||||
"""
|
||||
Remove empty or otherwise useless log files
|
||||
"""
|
||||
prefix = artifact_name + "-"
|
||||
|
||||
for logf in os.listdir(self.resultsdir):
|
||||
if not logf.startswith(prefix):
|
||||
continue
|
||||
|
||||
log_path = os.path.join(self.resultsdir, logf)
|
||||
|
||||
@@ -685,7 +689,7 @@ class MockModuleBuilder(GenericBuilder):
|
||||
|
||||
# Depending on the configuration settings, remove/keep useless log files
|
||||
if conf.mock_purge_useless_logs:
|
||||
self._purge_useless_logs()
|
||||
self._purge_useless_logs(artifact_name)
|
||||
|
||||
# We return BUILDING state here even when we know it is already
|
||||
# completed or failed, because otherwise utils.start_build_batch
|
||||
|
||||
Reference in New Issue
Block a user