Package: apt-file
Version: 2.4.1
Severity: normal
Tags: patch

I have an empty system cache, but a full user cache:

  $ ls /var/cache/apt/apt-file | wc -l
  0
  $ ls $HOME/.cache/apt-file | wc -l
  7

Searching produces an error:

  $ apt-file search foo
  E: The cache directory is empty. You need to run 'apt-file update' first.

Doing "apt-file update" tells me everything is up-to-date, but further
searches will still fail. The attached restricts that error to the case
where both caches are empty, and fixes the problem for me.

-- System Information:
Debian Release: 6.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.37-trunk-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages apt-file depends on:
ii  curl                          7.21.3-1   Get a file from an HTTP, HTTPS or 
ii  libapt-pkg-perl               0.1.24+b1  Perl interface to libapt-pkg
ii  libconfig-file-perl           1.50-2     Parses simple configuration files
ii  liblist-moreutils-perl        0.25~02-1  Perl module with additional list f
ii  libregexp-assemble-perl       0.34-5     Assemble multiple Regular Expressi
ii  perl                          5.10.1-17  Larry Wall's Practical Extraction 
ii  perl-modules [libfile-temp-pe 5.10.1-17  Core Perl modules

Versions of packages apt-file recommends:
ii  python-apt                    0.7.100.1  Python interface to libapt-pkg

Versions of packages apt-file suggests:
ii  openssh-client                1:5.5p1-6  secure shell (SSH) client, for sec
pn  sudo                          <none>     (no description available)

-- no debconf information
>From 58eae92049fb5acfd4f134fb7e33197c6c986af0 Mon Sep 17 00:00:00 2001
From: Jeff King <p...@peff.net>
Date: Mon, 7 Feb 2011 17:05:35 -0500
Subject: [PATCH] check both system and user cache for emptiness

We will use whichever is the more recent of the two caches.
However, the early check for "is the cache empty" could
uselessly trigger if the system cache was empty but the user
cache was not.

Signed-off-by: Jeff King <p...@peff.net>
---
 apt-file |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/apt-file b/apt-file
index ad4f6bf..a9f8d46 100755
--- a/apt-file
+++ b/apt-file
@@ -774,7 +774,8 @@ sub main {
     my $sources = parse_sources_list $Conf->{sources_list};
     errorx "No valid sources in @{$Conf->{sources_list}}" if !defined $sources;
 
-    if ( $Conf->{is_search} && dir_is_empty( $Conf->{cache} ) ) {
+    if ( $Conf->{is_search} && dir_is_empty( $Conf->{cache} )
+         && defined $Conf->{user_cache} && dir_is_empty( $Conf->{user_cache} ) ) {
         errorx "The cache directory is empty. You need to run 'apt-file update' first.";
     }
 
-- 
1.7.4.rc2.27.gd0787

Reply via email to