[Yum-devel] [PATCH] fix --cacheonly edge case. BZ 975619

James Antill james at fedoraproject.org
Wed Jun 19 14:04:51 UTC 2013


On Wed, 2013-06-19 at 09:30 +0200, Zdenek Pavlas wrote:
> When cacheonly and MD are not present/valid, we usually
> raise RepoError right in _retrieveMD().  But when the
> *compressed* file is valid, we try decompressing it.
> Make it fail in the expected way few lines below.

 Ok.

> ---
>  yum/yumRepo.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/yum/yumRepo.py b/yum/yumRepo.py
> index cfe7b05..e217c57 100644
> --- a/yum/yumRepo.py
> +++ b/yum/yumRepo.py
> @@ -234,7 +234,8 @@ class YumPackageSack(packageSack.PackageSack):
>                      db_fn = repo._retrieveMD(mydbtype)
>                      if db_fn:
>                          # unlink the decompressed file, we know it's not valid
> -                        misc.unlink_f(repo.cachedir +'/gen/%s.sqlite' % mydbtype)
> +                        try: os.unlink(repo.cachedir +'/gen/%s.sqlite' % mydbtype)
> +                        except OSError: pass

 I don't understand. misc.unlink_f() is:

    try:
        os.unlink(filename)
    except OSError, e:
        if e.errno != errno.ENOENT:
            raise

...so which other OSError's are we protecting ourself from here, and
why?
 Also would be better to have an all_oserrors=True (or maybe just
all_errors=True?) flag to unlink_f.



More information about the Yum-devel mailing list