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:
Owen W. Taylor
2020-12-07 13:24:08 -05:00
committed by breilly
parent 710e610850
commit 14597fb1a7

View File

@@ -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