[PATCH] fetch: Make FlatLayout.get_filenames() not return directories

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] fetch: Make FlatLayout.get_filenames() not return directories

Michał Górny-5
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 <[hidden email]>
---
 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


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] fetch: Make FlatLayout.get_filenames() not return directories

Zac Medico-2
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 <[hidden email]>
> ---
>  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


signature.asc (1000 bytes) Download Attachment