From 912e6e647f1ab1b2b8472cbb33ab287ff49e97ea Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Fri, 3 Jul 2015 19:20:11 +0200 Subject: [PATCH] Avoid flushing all the time in attachment import It slows everything down a lot... --- indico_zodbimport/modules/attachments.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/indico_zodbimport/modules/attachments.py b/indico_zodbimport/modules/attachments.py index ff98ce5ca..4a95406b2 100644 --- a/indico_zodbimport/modules/attachments.py +++ b/indico_zodbimport/modules/attachments.py @@ -82,6 +82,9 @@ class AttachmentImporter(Importer): return AttachmentFolder.has_rows or Attachment.has_rows def migrate(self): + # disable onupdate for attachment lastmod timestamp + # see https://bitbucket.org/zzzeek/sqlalchemy/issue/3471/ why it's needed + Attachment.__table__.columns.modified_dt.onupdate = None self.janitor_user = User.get_one(Config.getInstance().getJanitorUserId()) with patch_default_group_provider(self.default_group_provider): self.migrate_category_attachments() @@ -198,7 +201,8 @@ class AttachmentImporter(Importer): data = {'folder': folder, 'user': self.janitor_user, 'title': convert_to_unicode(resource.name).strip() or folder.title, - 'description': convert_to_unicode(resource.description)} + 'description': convert_to_unicode(resource.description), + 'modified_dt': modified_dt} if resource.__class__.__name__ == 'Link': data['type'] = AttachmentType.link data['link_url'] = resource.url @@ -216,9 +220,6 @@ class AttachmentImporter(Importer): attachment = Attachment(**data) protection_from_ac(attachment, resource._Resource__ac) db.session.add(attachment) - # https://bitbucket.org/zzzeek/sqlalchemy/issue/3471/onupdate-runs-for-post_update-updates - db.session.flush() - attachment.modified_dt = modified_dt return attachment def _has_special_protection(self, material, resource): -- 2.11.4.GIT