Просмотр исходного кода

* apt-pkg/deb/debindexfile.cc:
- Use FileFd::Size() instead of stat()ing the sources/binary/translations
indexes directly, so that we have transparent handling of gzipped
indexes.

Martin Pitt лет назад: 15
Родитель
Сommit
5473df3fec
2 измененных файлов с 19 добавлено и 9 удалено
  1. 13 9
      apt-pkg/deb/debindexfile.cc
  2. 6 0
      debian/changelog

+ 13 - 9
apt-pkg/deb/debindexfile.cc

@@ -149,10 +149,11 @@ bool debSourcesIndex::Exists() const
 /* */
 /* */
 unsigned long debSourcesIndex::Size() const
 unsigned long debSourcesIndex::Size() const
 {
 {
-   struct stat S;
-   if (stat(IndexFile("Sources").c_str(),&S) != 0)
+   FileFd f = FileFd (IndexFile("Sources"), FileFd::ReadOnlyGzip);
+
+   if (f.Failed())
       return 0;
       return 0;
-   return S.st_size;
+   return f.Size();
 }
 }
 									/*}}}*/
 									/*}}}*/
 
 
@@ -268,10 +269,11 @@ bool debPackagesIndex::Exists() const
 /* This is really only used for progress reporting. */
 /* This is really only used for progress reporting. */
 unsigned long debPackagesIndex::Size() const
 unsigned long debPackagesIndex::Size() const
 {
 {
-   struct stat S;
-   if (stat(IndexFile("Packages").c_str(),&S) != 0)
+   FileFd f = FileFd (IndexFile("Packages"), FileFd::ReadOnlyGzip);
+
+   if (f.Failed())
       return 0;
       return 0;
-   return S.st_size;
+   return f.Size();
 }
 }
 									/*}}}*/
 									/*}}}*/
 // PackagesIndex::Merge - Load the index file into a cache		/*{{{*/
 // PackagesIndex::Merge - Load the index file into a cache		/*{{{*/
@@ -458,10 +460,12 @@ bool debTranslationsIndex::Exists() const
 /* This is really only used for progress reporting. */
 /* This is really only used for progress reporting. */
 unsigned long debTranslationsIndex::Size() const
 unsigned long debTranslationsIndex::Size() const
 {
 {
-   struct stat S;
-   if (stat(IndexFile(Language).c_str(),&S) != 0)
+   FileFd f = FileFd (IndexFile(Language), FileFd::ReadOnlyGzip);
+
+   if (f.Failed())
       return 0;
       return 0;
-   return S.st_size;
+
+   return f.Size();
 }
 }
 									/*}}}*/
 									/*}}}*/
 // TranslationsIndex::Merge - Load the index file into a cache		/*{{{*/
 // TranslationsIndex::Merge - Load the index file into a cache		/*{{{*/

+ 6 - 0
debian/changelog

@@ -6,6 +6,12 @@ apt (0.8.7) UNRELEASED; urgency=low
   * Wrong translation for "showauto" fixed. Thanks to Raphaël Hertzog
   * Wrong translation for "showauto" fixed. Thanks to Raphaël Hertzog
     Closes: #599265
     Closes: #599265
 
 
+  [ Martin Pitt ]
+  * apt-pkg/deb/debindexfile.cc:
+    - Use FileFd::Size() instead of stat()ing the sources/binary/translations
+      indexes directly, so that we have transparent handling of gzipped
+      indexes.
+
  -- Christian Perrier <bubulle@debian.org>  Tue, 05 Oct 2010 05:35:58 +0200
  -- Christian Perrier <bubulle@debian.org>  Tue, 05 Oct 2010 05:35:58 +0200
 
 
 apt (0.8.6) unstable; urgency=low
 apt (0.8.6) unstable; urgency=low