public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/_emirrordist/
Date: Sun, 13 Oct 2019 19:39:30 +0000 (UTC)	[thread overview]
Message-ID: <1570995532.87c1f0d53eebfeda28f17400b072d8ffa76732dc.mgorny@gentoo> (raw)

commit:     87c1f0d53eebfeda28f17400b072d8ffa76732dc
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 12 11:04:29 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Oct 13 19:38:52 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=87c1f0d5

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 <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/466
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 lib/portage/_emirrordist/FetchTask.py | 54 ++++++++++++++++++++---------------
 1 file 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


             reply	other threads:[~2019-10-13 19:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-13 19:39 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-05-24  5:25 [gentoo-commits] proj/portage:master commit in: lib/portage/_emirrordist/ Zac Medico
2021-02-27  3:57 Zac Medico
2021-01-22  7:27 Zac Medico
2020-08-03 21:42 Zac Medico
2020-08-03 19:30 Zac Medico
2019-11-07  6:29 Zac Medico
2019-11-06 20:04 Zac Medico
2019-11-05 19:16 Zac Medico
2019-10-21 13:38 Michał Górny
2019-10-21  8:09 Michał Górny
2019-10-21  7:40 Michał Górny
2019-10-17 18:09 Michał Górny
2019-10-12  6:40 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1570995532.87c1f0d53eebfeda28f17400b072d8ffa76732dc.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox