summaryrefslogtreecommitdiff
path: root/devel/management/commands
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-23 17:59:54 -0500
committerDan McGee <dan@archlinux.org>2012-03-23 19:54:40 -0500
commit5575b68272f1bc773f98ecdfd679e58e8be2ac9b (patch)
tree3c5d537cd19bc7a84abce1becf7865b04a98d0b3 /devel/management/commands
parent6218ccc570c674bfaaf1c636382ac6f9adbf212b (diff)
reporead: use Django 1.4 select_for_update()
As per TODO comments in the existing code. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/management/commands')
-rw-r--r--devel/management/commands/reporead.py17
1 files changed, 2 insertions, 15 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 8369b6ec..ebf17111 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -286,17 +286,6 @@ def populate_files(dbpkg, repopkg, force=False):
dbpkg.save()
-def select_pkg_for_update(dbpkg):
- database = router.db_for_write(Package, instance=dbpkg)
- connection = connections[database]
- if 'sqlite' in connection.settings_dict['ENGINE'].lower():
- return dbpkg
- new_pkg = Package.objects.raw(
- 'SELECT * FROM packages WHERE id = %s FOR UPDATE',
- [dbpkg.id])
- return list(new_pkg)[0]
-
-
def update_common(archname, reponame, pkgs, sanity_check=True):
# If isolation level is repeatable-read, we need to ensure each package
# update starts a new transaction and re-queries the database as
@@ -396,8 +385,7 @@ def db_update(archname, reponame, pkgs, force=False):
# simultaneous updates don't happen on a package, causing
# files/depends/all related items to be double-imported.
with transaction.commit_on_success():
- # TODO Django 1.4 select_for_update() will work once released
- dbpkg = select_pkg_for_update(dbpkg)
+ dbpkg = Package.objects.select_for_update().get(id=dbpkg.id)
if not force and pkg_same_version(pkg, dbpkg):
logger.debug("Package %s was already updated", pkg.name)
continue
@@ -428,8 +416,7 @@ def filesonly_update(archname, reponame, pkgs, force=False):
elif not force and dbpkg.files_last_update > dbpkg.last_update:
logger.debug("Files for %s are up to date", pkg.name)
continue
- # TODO Django 1.4 select_for_update() will work once released
- dbpkg = select_pkg_for_update(dbpkg)
+ dbpkg = Package.objects.select_for_update().get(id=dbpkg.id)
logger.debug("Checking files for package %s", pkg.name)
populate_files(dbpkg, pkg, force=force)