From 95520ae26485e5c62ea1431ca82a7b42d01b923a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 23 Mar 2012 18:03:28 -0500 Subject: reporead: use Django 1.4 bulk_create() for package files Signed-off-by: Dan McGee --- devel/management/commands/reporead.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py index ebf1711..a8c58ba 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() -- cgit v1.2.3-24-g4f1b