[Secure-testing-commits] r2031 - lib/python
Florian Weimer
fw at costa.debian.org
Sat Sep 17 13:19:32 UTC 2005
Author: fw
Date: 2005-09-17 13:19:32 +0000 (Sat, 17 Sep 2005)
New Revision: 2031
Modified:
lib/python/security_db.py
Log:
lib/python/security_db.py (DB._readBinaryPackages):
Skip reading entirely if there are no changes.
Modified: lib/python/security_db.py
===================================================================
--- lib/python/security_db.py 2005-09-17 13:02:49 UTC (rev 2030)
+++ lib/python/security_db.py 2005-09-17 13:19:32 UTC (rev 2031)
@@ -456,9 +456,33 @@
if self.verbose:
print " reading binary packages"
+ # First check for any changes.
+
+ filenames = glob.glob(directory + '/*_Packages')
+ filenames.sort()
+ changed = False
+ for filename in filenames:
+ changed = True
+ for (old_print,) in cursor.execute(
+ "SELECT inodeprint FROM inodeprints WHERE file = ?",
+ (filename,)):
+ if self.filePrint(filename) == old_print:
+ changed = False
+ if changed:
+ break
+ if not changed:
+ if self.verbose:
+ print " finished (no changes)"
+ return
+
+ # Real import. We have to re-read all Packages files even if
+ # only some of them have changed because the database only
+ # stores aggregated data, and there is no efficient way to
+ # handle updates of the records related to a single file.
+
packages = {}
unchanged = True
- for filename in glob.glob(directory + '/*_Packages'):
+ for filename in filenames:
match = re_packages.match(filename)
if match is None:
raise ValueError, "invalid file name: " + `filename`
@@ -505,7 +529,7 @@
yield key + (archs,)
if self.verbose:
- print " storing binary package data"
+ print " storing binary package data"
cursor.executemany(
"""INSERT INTO binary_packages
More information about the Secure-testing-commits
mailing list