summaryrefslogtreecommitdiff
path: root/devel/management/commands
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-11-04 22:11:00 -0500
committerDan McGee <dan@archlinux.org>2010-11-04 22:11:00 -0500
commitfcc6d98bc438ea917c757ee1a565a5dba625f333 (patch)
tree69275d1942d6a8ef73f9dfaafd955f900d275f62 /devel/management/commands
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 <dan@archlinux.org>
Diffstat (limited to 'devel/management/commands')
-rw-r--r--devel/management/commands/reporead.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index ef30977e..6f7fd958 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -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:
+ logger.info("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:
pass
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__:
dbpkg.packagefile_set.all().delete()
- logger.info("adding %d files for package %s" % (len(repopkg.files), dbpkg.pkgname))
+ logger.info("adding %d files for package %s" %
+ (len(repopkg.files), dbpkg.pkgname))
for x in repopkg.files:
dbpkg.packagefile_set.create(path=x)
dbpkg.files_last_update = datetime.now()
@@ -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:
logger.error(msg)
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:
pass
- elif '-'.join((p.ver, p.rel)) == '-'.join((dbp.pkgver, dbp.pkgrel)):
+ elif p.ver == dbp.pkgver and p.rel == dbp.pkgrel:
if not force:
continue
else:
timestamp = datetime.now()
if filesonly:
logger.debug("Checking files for package %s in database", p.name)
- populate_files(dbp, p)
+ populate_files(dbp, p, force=force)
else:
logger.info("Updating package %s in database", p.name)
populate_pkg(dbp, p, force=force, timestamp=timestamp)