Commit ef014a5d authored by Łukasz Nowak's avatar Łukasz Nowak

- disallow to do more than one migration, support concurrent case of migration invocation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25458 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 31eabfd5
...@@ -78,6 +78,9 @@ import os ...@@ -78,6 +78,9 @@ import os
from zLOG import LOG, PROBLEM, WARNING from zLOG import LOG, PROBLEM, WARNING
import warnings import warnings
# variable to inform about migration process
migration_process_lock = "_migration_in_progress"
REINDEX_SPLIT_COUNT = 100 # if folder containes more than this, reindexing should be splitted. REINDEX_SPLIT_COUNT = 100 # if folder containes more than this, reindexing should be splitted.
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
...@@ -441,6 +444,17 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn, ...@@ -441,6 +444,17 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
Then it will migrate foder from btree to hbtree. Then it will migrate foder from btree to hbtree.
""" """
BUNDLE_COUNT = 10 BUNDLE_COUNT = 10
# if folder is already migrated or migration process is in progress
# do not do anything beside logging
if getattr(self, migration_process_lock, None) is not None \
or self.isHBTree():
LOG('migrateToHBTree', WARNING,
'Folder %s already migrated'%(self.getPath(),))
return
# lock folder migration early
setattr(self, migration_process_lock, 1)
# we may want to change all objects ids before migrating to new folder type # we may want to change all objects ids before migrating to new folder type
# set new id generator here so that object created while migration # set new id generator here so that object created while migration
# got a right id # got a right id
...@@ -480,6 +494,8 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn, ...@@ -480,6 +494,8 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
""" """
if getattr(self, "_tree", None) is not None: if getattr(self, "_tree", None) is not None:
delattr(self, "_tree") delattr(self, "_tree")
if getattr(self, migration_process_lock, None) is not None:
delattr(self, migration_process_lock)
def _launchCopyObjectToHBTree(self, tag): def _launchCopyObjectToHBTree(self, tag):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment