public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] fetch: Make FlatLayout.get_filenames() not return directories
@ 2019-10-13 11:57 Michał Górny
  2019-10-13 19:32 ` Zac Medico
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2019-10-13 11:57 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Stop returning directories from FlatLayout.get_filenames().  This causes
emirrordist to wrongly presume directories created by new layout
to be distfiles, and causes some noisy errors.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 lib/portage/package/ebuild/fetch.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py
index 5d0bc7355..793402137 100644
--- a/lib/portage/package/ebuild/fetch.py
+++ b/lib/portage/package/ebuild/fetch.py
@@ -269,7 +269,8 @@ class FlatLayout(object):
 		return filename
 
 	def get_filenames(self, distdir):
-		return iter(os.listdir(distdir))
+		for dirpath, dirnames, filenames in os.walk(distdir):
+			return iter(filenames)
 
 	@staticmethod
 	def verify_args(args):
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] fetch: Make FlatLayout.get_filenames() not return directories
  2019-10-13 11:57 [gentoo-portage-dev] [PATCH] fetch: Make FlatLayout.get_filenames() not return directories Michał Górny
@ 2019-10-13 19:32 ` Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2019-10-13 19:32 UTC (permalink / raw
  To: gentoo-portage-dev, Michał Górny


[-- Attachment #1.1: Type: text/plain, Size: 1199 bytes --]

On 10/13/19 4:57 AM, Michał Górny wrote:
> Stop returning directories from FlatLayout.get_filenames().  This causes
> emirrordist to wrongly presume directories created by new layout
> to be distfiles, and causes some noisy errors.
> 
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> ---
>  lib/portage/package/ebuild/fetch.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py
> index 5d0bc7355..793402137 100644
> --- a/lib/portage/package/ebuild/fetch.py
> +++ b/lib/portage/package/ebuild/fetch.py
> @@ -269,7 +269,8 @@ class FlatLayout(object):
>  		return filename
>  
>  	def get_filenames(self, distdir):
> -		return iter(os.listdir(distdir))
> +		for dirpath, dirnames, filenames in os.walk(distdir):
> +			return iter(filenames)

Since os.walk will silently fail if distdir suddenly disappears somehow,
we should use the onerror parameter to force it to raise an exception in
this (albeit unlikely) case. The portage.util.install_mask._raise_exc
function works perfectly well for this kind of onerror handler.

Otherwise, looks good.
-- 
Thanks,
Zac


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 981 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-13 19:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-13 11:57 [gentoo-portage-dev] [PATCH] fetch: Make FlatLayout.get_filenames() not return directories Michał Górny
2019-10-13 19:32 ` Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox