summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/fetch_strategy.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 0d0a7db8a9..4ea87bea7e 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -289,8 +289,14 @@ class URLFetchStrategy(FetchStrategy):
if not self.archive_file:
raise NoArchiveFileError("Tried to reset URLFetchStrategy before fetching",
"Failed on reset() for URL %s" % self.url)
- if self.stage.source_path:
- shutil.rmtree(self.stage.source_path, ignore_errors=True)
+
+ # Remove everythigng but the archive from the stage
+ for filename in os.listdir(self.stage.path):
+ abspath = os.path.join(self.stage.path, filename)
+ if abspath != self.archive_file:
+ shutil.rmtree(abspath, ignore_errors=True)
+
+ # Expand the archive again
self.expand()
def __repr__(self):