summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-24 00:22:25 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-24 00:24:22 +0100
commitdcaf88795c06b151ca32ca9b79b2043c4068f45c (patch)
treebf0274bf59a8f1a5274dda361d1a287cd1c708cd
parent3e1f3fdedc03bb25712481a1315d1b35753bfc3d (diff)
downloadIshtar-dcaf88795c06b151ca32ca9b79b2043c4068f45c.tar.bz2
Ishtar-dcaf88795c06b151ca32ca9b79b2043c4068f45c.zip
Migration optimization: no move of doc on index gen
-rw-r--r--ishtar_common/migrations/0083_document_index_external_id.py1
-rw-r--r--ishtar_common/models.py4
2 files changed, 5 insertions, 0 deletions
diff --git a/ishtar_common/migrations/0083_document_index_external_id.py b/ishtar_common/migrations/0083_document_index_external_id.py
index 9d339b20e..593962885 100644
--- a/ishtar_common/migrations/0083_document_index_external_id.py
+++ b/ishtar_common/migrations/0083_document_index_external_id.py
@@ -8,6 +8,7 @@ from django.db import migrations
def gen_index(apps, schema_editor):
from ishtar_common.models import Document
for doc in Document.objects.all():
+ doc._no_move = True
doc.save()
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index e04efbcab..425ee2a8d 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -4098,6 +4098,8 @@ class Document(BaseHistorizedItem, OwnPerms, ImageModel):
:return: list of associated links
"""
+ if getattr(self, "_no_move", False):
+ return
reference_path = None
initial_path = self.image.path
filename = os.path.basename(initial_path)
@@ -4174,6 +4176,8 @@ class Document(BaseHistorizedItem, OwnPerms, ImageModel):
if self.image and not no_path_change and \
not getattr(self, '_no_path_change', False):
links = self._move_image()
+ if not links:
+ return
links = self.LINK_SPLIT.join(links)
if links != self.associated_links:
self.associated_links = links