summaryrefslogtreecommitdiff
path: root/devel/management
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-11-14 22:44:27 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-11-14 22:44:27 -0500
commit64f6dd9cb41ddbc84376549f558ed7d52d9e600a (patch)
tree81f31f1ceb5fc6e4d94508d273003996e036191c /devel/management
parentbc432a1ff0e69bf45c5f3b97077a13952611196d (diff)
parentb2b5c1a064d5d3c33f4c4fc119bd67cf9ca1b7ba (diff)
Merge tag 'release_2012-01-11'
Pkgbase view in todos, other changes related to caching Conflicts: public/views.py
Diffstat (limited to 'devel/management')
-rw-r--r--devel/management/commands/reporead.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 4dd26091..bf1b2562 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -24,7 +24,6 @@ from datetime import datetime
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
-from django.contrib.auth.models import User
from django.db import connections, router, transaction
from django.db.utils import IntegrityError
@@ -91,6 +90,7 @@ class Pkg(object):
setattr(self, k, None)
for k in self.collections:
setattr(self, k, ())
+ self.builddate = None
self.files = None
self.has_files = False
@@ -244,6 +244,12 @@ pkg_same_version = lambda pkg, dbpkg: pkg.ver == dbpkg.pkgver \
and pkg.rel == dbpkg.pkgrel and pkg.epoch == dbpkg.epoch
+def delete_pkg_files(dbpkg):
+ database = router.db_for_write(Package, instance=dbpkg)
+ cursor = connections[database].cursor()
+ cursor.execute('DELETE FROM package_files WHERE pkg_id = %s', [dbpkg.id])
+
+
def populate_files(dbpkg, repopkg, force=False):
if not force:
if not pkg_same_version(repopkg, dbpkg):
@@ -258,7 +264,7 @@ def populate_files(dbpkg, repopkg, force=False):
# only delete files if we are reading a DB that contains them
if repopkg.has_files:
- dbpkg.packagefile_set.all().delete()
+ delete_pkg_files(dbpkg)
logger.info("adding %d files for package %s",
len(repopkg.files), dbpkg.pkgname)
for f in repopkg.files:
@@ -267,6 +273,7 @@ def populate_files(dbpkg, repopkg, force=False):
filename = None
# this is basically like calling dbpkg.packagefile_set.create(),
# but much faster as we can skip a lot of the repeated code paths
+ # TODO use Django 1.4 bulk_create
pkgfile = PackageFile(pkg=dbpkg,
is_directory=(filename is None),
directory=dirname + '/',
@@ -366,6 +373,7 @@ def db_update(archname, reponame, pkgs, force=False):
with transaction.commit_on_success():
# no race condition here as long as simultaneous threads both
# issue deletes; second delete will be a no-op
+ delete_pkg_files(dbpkg)
dbpkg.delete()
# packages in both database and in syncdb (update in database)