diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-01 14:14:41 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-05 12:54:45 +0000 |
commit | d873baa12f36e07e3f6d3b7f808d7f2f10763605 (patch) | |
tree | f196145d42a0183f6b3430b8834e69bd3fc0d819 /morphlib/stagingarea.py | |
parent | 061834bd983909ccf37927f4c0c5dd4eca827040 (diff) | |
download | morph-d873baa12f36e07e3f6d3b7f808d7f2f10763605.tar.gz |
morphlib: Use new temp_dir helper context manager
Change-Id: Ie4e024a63f2ab1c7ea66f2cbedaef99c9adf5e69
Diffstat (limited to 'morphlib/stagingarea.py')
-rw-r--r-- | morphlib/stagingarea.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py index 8c2781aa..76bb3a18 100644 --- a/morphlib/stagingarea.py +++ b/morphlib/stagingarea.py @@ -161,13 +161,10 @@ class StagingArea(object): self._app.status( msg='Unpacking chunk from cache %(filename)s', filename=os.path.basename(handle.name)) - savedir = tempfile.mkdtemp(dir=chunk_cache_dir) - try: + with morphlib.util.temp_dir(dir=chunk_cache_dir, + cleanup_on_success=False) as savedir: morphlib.bins.unpack_binary_from_file( handle, savedir + '/') - except BaseException as e: # pragma: no cover - shutil.rmtree(savedir) - raise # TODO: This rename is not concurrency safe if two builds are # extracting the same chunk, one build will fail because # the other renamed its tempdir here first. |