summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'pym/_emerge/__init__.py')
-rw-r--r--pym/_emerge/__init__.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 81f0f3667..d416bb6b3 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -3409,7 +3409,18 @@ class BinpkgFetcher(SpawnProcess):
settings = bintree.settings
use_locks = "distlocks" in settings.features
pkg_path = self.pkg_path
- resume = os.path.exists(pkg_path)
+
+ portage.util.ensure_dirs(os.path.dirname(pkg_path))
+ if use_locks:
+ self.lock()
+ exists = os.path.exists(pkg_path)
+ resume = exists and os.path.basename(pkg_path) in bintree.invalids
+ if not resume:
+ # Remove existing file or broken symlink.
+ try:
+ os.unlink(pkg_path)
+ except OSError:
+ pass
# urljoin doesn't work correctly with
# unrecognized protocols like sftp
@@ -3441,10 +3452,6 @@ class BinpkgFetcher(SpawnProcess):
fetch_args = [portage.util.varexpand(x, mydict=fcmd_vars) \
for x in shlex.split(fcmd)]
- portage.util.ensure_dirs(os.path.dirname(pkg_path))
- if use_locks:
- self.lock()
-
if self.fd_pipes is None:
self.fd_pipes = {}
fd_pipes = self.fd_pipes