diff options
authorDan McGee <>2010-11-04 22:11:00 -0500
committerDan McGee <>2010-11-04 22:11:00 -0500
commitfcc6d98bc438ea917c757ee1a565a5dba625f333 (patch)
parent01cb0348e30b31c15a4bebbe3ecfb4605509d29d (diff)
reporead: fix small issues when loading files databasesrelease_2010-11-04
We didn't verify that the version in the files database was the same as in the SQL side of things, so we could load old files for a new package and lose track of this fact. When loading files, ensure the database version matches the version in the package before continuing with the file load operation. There are also a few other small updates in here, like skipping the sanity check for filesonly as we never delete packages, and removing some unnecessary string concatenation operations. Signed-off-by: Dan McGee <>
1 files changed, 14 insertions, 4 deletions
diff --git a/devel/management/commands/ b/devel/management/commands/
index ef30977e..6f7fd958 100644
--- a/devel/management/commands/
+++ b/devel/management/commands/
@@ -212,6 +212,13 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
def populate_files(dbpkg, repopkg, force=False):
if not force:
+ if dbpkg.pkgver != repopkg.ver or dbpkg.pkgrel != repopkg.rel:
+"db version (%s) didn't match repo version (%s) "
+ "for package %s, skipping file list addition" %
+ ('-'.join((dbpkg.pkgver, dbpkg.pkgrel)),
+ '-'.join((repopkg.ver, repopkg.rel)),
+ dbpkg.pkgname))
+ return
if not dbpkg.files_last_update or not dbpkg.last_update:
elif dbpkg.files_last_update > dbpkg.last_update:
@@ -219,7 +226,8 @@ def populate_files(dbpkg, repopkg, force=False):
# only delete files if we are reading a DB that contains them
if 'files' in repopkg.__dict__:
-"adding %d files for package %s" % (len(repopkg.files), dbpkg.pkgname))
+"adding %d files for package %s" %
+ (len(repopkg.files), dbpkg.pkgname))
for x in repopkg.files:
dbpkg.files_last_update =
@@ -267,7 +275,9 @@ def db_update(archname, reponame, pkgs, options):
# means we expect the repo to fluctuate a lot.
msg = "Package database has %.1f%% the number of packages in the " \
"web database" % dbpercent
- if len(dbset) > 20 and dbpercent < 50.0 and not repository.testing:
+ if not filesonly and \
+ len(dbset) > 20 and dbpercent < 50.0 and \
+ not repository.testing:
raise Exception(msg)
if dbpercent < 75.0:
@@ -297,14 +307,14 @@ def db_update(archname, reponame, pkgs, options):
# for a non-force, we don't want to do anything at all.
if filesonly:
- elif '-'.join((p.ver, p.rel)) == '-'.join((dbp.pkgver, dbp.pkgrel)):
+ elif p.ver == dbp.pkgver and p.rel == dbp.pkgrel:
if not force:
timestamp =
if filesonly:
logger.debug("Checking files for package %s in database",
- populate_files(dbp, p)
+ populate_files(dbp, p, force=force)
else:"Updating package %s in database",
populate_pkg(dbp, p, force=force, timestamp=timestamp)