summaryrefslogtreecommitdiffstats
path: root/devel
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-02 03:21:34 +0200
committerDan McGee <dan@archlinux.org>2012-07-02 03:21:34 +0200
commita87fe016d1a1bf7fdcd2b19f515aa72a5b93db2b (patch)
treec2dd261f4f0ea8c6610b3f0ce5e165a5e542dbfb /devel
parent43b5c29b3d89cc2e7e7109bb3c7717a87cfc67b5 (diff)
downloadarchweb-a87fe016d1a1bf7fdcd2b19f515aa72a5b93db2b.tar.gz
archweb-a87fe016d1a1bf7fdcd2b19f515aa72a5b93db2b.tar.xz
Log package updates during reporead invocation
This adds a Manager and log_update method to help log all updates made to the packages table during reporead runs. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel')
-rw-r--r--devel/management/commands/reporead.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 2e8c462..4e242af 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -14,6 +14,7 @@ Example:
"""
from collections import defaultdict
+from copy import copy
import io
import os
import re
@@ -31,7 +32,7 @@ from django.db.utils import IntegrityError
from devel.utils import UserFinder
from main.models import Arch, Package, PackageFile, Repo
from main.utils import utc_now
-from packages.models import Depend, Conflict, Provision, Replacement
+from packages.models import Depend, Conflict, Provision, Replacement, Update
logging.basicConfig(
@@ -362,6 +363,7 @@ def db_update(archname, reponame, pkgs, force=False):
try:
with transaction.commit_on_success():
populate_pkg(dbpkg, pkg, timestamp=utc_now())
+ Update.objects.log_update(None, dbpkg)
except IntegrityError:
logger.warning("Could not add package %s; "
"not fatal if another thread beat us to it.",
@@ -372,6 +374,7 @@ def db_update(archname, reponame, pkgs, force=False):
logger.info("Removing package %s", pkgname)
dbpkg = dbdict[pkgname]
with transaction.commit_on_success():
+ Update.objects.log_update(dbpkg, None)
# no race condition here as long as simultaneous threads both
# issue deletes; second delete will be a no-op
delete_pkg_files(dbpkg)
@@ -399,7 +402,9 @@ def db_update(archname, reponame, pkgs, force=False):
logger.debug("Package %s was already updated", pkg.name)
continue
logger.info("Updating package %s", pkg.name)
+ prevpkg = copy(dbpkg)
populate_pkg(dbpkg, pkg, force=force, timestamp=timestamp)
+ Update.objects.log_update(prevpkg, dbpkg)
logger.info('Finished updating arch: %s', archname)