summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-23 18:03:28 -0500
committerDan McGee <dan@archlinux.org>2012-03-23 19:54:40 -0500
commit95520ae26485e5c62ea1431ca82a7b42d01b923a (patch)
treee661cdbb90e5c5980506caf9d467c3486a6501ed
parent5575b68272f1bc773f98ecdfd679e58e8be2ac9b (diff)
reporead: use Django 1.4 bulk_create() for package files
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--devel/management/commands/reporead.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index ebf17111..a8c58ba7 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -270,18 +270,17 @@ def populate_files(dbpkg, repopkg, force=False):
delete_pkg_files(dbpkg)
logger.info("adding %d files for package %s",
len(repopkg.files), dbpkg.pkgname)
+ pkg_files = []
for f in repopkg.files:
dirname, filename = f.rsplit('/', 1)
if filename == '':
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 + '/',
filename=filename)
- pkgfile.save(force_insert=True)
+ pkg_files.append(pkgfile)
+ PackageFile.objects.bulk_create(pkg_files)
dbpkg.files_last_update = datetime.utcnow()
dbpkg.save()