aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2019-10-12 13:04:29 +0200
committerMichał Górny <mgorny@gentoo.org>2019-10-13 21:38:52 +0200
commit87c1f0d53eebfeda28f17400b072d8ffa76732dc (patch)
tree827bfe84bf2f600e66c266beba5027c043f58eab /lib/portage/_emirrordist/FetchTask.py
parentman/emirrordist.1: document new options (diff)
downloadportage-87c1f0d53eebfeda28f17400b072d8ffa76732dc.tar.gz
portage-87c1f0d53eebfeda28f17400b072d8ffa76732dc.tar.bz2
portage-87c1f0d53eebfeda28f17400b072d8ffa76732dc.zip
emirrordist: Refetch only if none of the layouts have the file
Check all layouts for a file before refetching it. This is helpful when combined with --layout-conf that specifies the new layout as primary to cover new files but user-oriented layout.conf still uses old layout. Reviewed-by: Zac Medico <zmedico@gentoo.org> Closes: https://github.com/gentoo/portage/pull/466 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'lib/portage/_emirrordist/FetchTask.py')
-rw-r--r--lib/portage/_emirrordist/FetchTask.py54
1 files changed, 31 insertions, 23 deletions
diff --git a/lib/portage/_emirrordist/FetchTask.py b/lib/portage/_emirrordist/FetchTask.py
index 7b68b7d3e..6f547d397 100644
--- a/lib/portage/_emirrordist/FetchTask.py
+++ b/lib/portage/_emirrordist/FetchTask.py
@@ -61,23 +61,24 @@ class FetchTask(CompositeTask):
self._async_wait()
return
- distfile_path = os.path.join(
- self.config.options.distfiles,
- self.config.layouts[0].get_path(self.distfile))
-
st = None
- size_ok = False
- try:
- st = os.stat(distfile_path)
- except OSError as e:
- if e.errno not in (errno.ENOENT, errno.ESTALE):
- msg = "%s stat failed in %s: %s" % \
- (self.distfile, "distfiles", e)
- self.scheduler.output(msg + '\n', background=True,
- log_path=self._log_path)
- logging.error(msg)
- else:
- size_ok = st.st_size == self.digests["size"]
+ for layout in self.config.layouts:
+ distfile_path = os.path.join(
+ self.config.options.distfiles,
+ layout.get_path(self.distfile))
+ try:
+ st = os.stat(distfile_path)
+ except OSError as e:
+ if e.errno not in (errno.ENOENT, errno.ESTALE):
+ msg = "%s stat failed in %s: %s" % \
+ (self.distfile, "distfiles", e)
+ self.scheduler.output(msg + '\n', background=True,
+ log_path=self._log_path)
+ logging.error(msg)
+ else:
+ break
+
+ size_ok = st is not None and st.st_size == self.digests["size"]
if not size_ok:
if self.config.options.dry_run:
@@ -88,13 +89,20 @@ class FetchTask(CompositeTask):
# Do the unlink in order to ensure that the path is clear,
# even if stat raised ENOENT, since a broken symlink can
# trigger ENOENT.
- if self._unlink_file(distfile_path, "distfiles"):
- if st is not None:
- logging.debug(("delete '%s' with "
- "wrong size from distfiles") % (self.distfile,))
- else:
- self.config.log_failure("%s\t%s\t%s" %
- (self.cpv, self.distfile, "unlink failed in distfiles"))
+ unlink_success = True
+ for layout in self.config.layouts:
+ unlink_path = os.path.join(
+ self.config.options.distfiles,
+ layout.get_path(self.distfile))
+ if self._unlink_file(unlink_path, "distfiles"):
+ if st is not None:
+ logging.debug(("delete '%s' with "
+ "wrong size from distfiles") % (self.distfile,))
+ else:
+ self.config.log_failure("%s\t%s\t%s" %
+ (self.cpv, self.distfile, "unlink failed in distfiles"))
+ unlink_success = False
+ if not unlink_success:
self.returncode = os.EX_OK
self._async_wait()
return