mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-02 10:20:31 +08:00
Ensure temporary directories are cleaned up always.
Previously, if SCM.checkout() raised an exception, the created temporary directory would be left over.
This commit is contained in:
10
rida/scm.py
10
rida/scm.py
@@ -167,13 +167,21 @@ class SCM(object):
|
||||
hc.close()
|
||||
return True if rc == 200 else False
|
||||
else:
|
||||
td = None
|
||||
try:
|
||||
td = tempfile.mkdtemp()
|
||||
self.checkout(td)
|
||||
shutil.rmtree(td)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
finally:
|
||||
try:
|
||||
if td is not None:
|
||||
shutil.rmtree(td)
|
||||
except Exception as e:
|
||||
log.warning(
|
||||
"Failed to remove temporary directory {!r}: {}".format(
|
||||
td, str(e)))
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
|
||||
Reference in New Issue
Block a user