stage: save: remove link from cache if cache already exists

Fixes #447

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-02-02 16:53:35 +02:00
parent fc7d3eb1d2
commit e97c1a5563
+5 -1
View File
@@ -285,7 +285,11 @@ class Output(Dependency):
cache = self.project.cache.get(md5)
cache_info = os.path.join(self.cache, relpath)
self.hardlink(path, cache)
if os.path.exists(cache):
self._remove(path, None)
self.hardlink(cache, path)
else:
self.hardlink(path, cache)
os.makedirs(os.path.dirname(cache_info))
with open(cache_info, 'w') as fd: