Skip to content

Commit

Permalink
Fix mass copy/paste async task (#582)
Browse files Browse the repository at this point in the history
* Remove batch transaction logic

* Remove unused code

* Add to changelog
  • Loading branch information
miknevinas authored Mar 26, 2024
1 parent af5b5c5 commit 2331ac7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
3.0.0b134 (unreleased)
----------------------

- Nothing changed yet.
- Fix mass copy/paste functionality


3.0.0b133 (2024-03-21)
Expand Down
16 changes: 0 additions & 16 deletions castle/cms/tasks/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ def paste_error_handle(where, op, mdatas):
def _paste_items(where, op, mdatas):
logger.info('Copying a bunch of items')
portal = api.portal.get()
catalog = api.portal.get_tool('portal_catalog')
dest = portal.restrictedTraverse(str(where.lstrip('/')))

count = 0
commit_count = 0
if not getCelery().conf.task_always_eager:
portal._p_jar.sync()

Expand All @@ -58,7 +55,6 @@ def _paste_items(where, op, mdatas):
pass

for mdata in mdatas[:]:
count += len(catalog(path={'query': '/'.join(mdata), 'depth': -1}))
ob = portal.unrestrictedTraverse(str('/'.join(mdata)), None)
if ob is None:
continue
Expand All @@ -68,18 +64,6 @@ def _paste_items(where, op, mdatas):
else:
api.content.move(ob, dest, safe_id=True)

if count / 50 != commit_count:
# commit every 50 objects moved
transaction.commit()
commit_count = count / 50
if not getCelery().conf.task_always_eager:
portal._p_jar.sync()
# so we do not redo it
try:
mdatas.remove(mdata)
except Exception:
pass

# we commit here so we can trigger conflict errors before
# trying to send email
transaction.commit()
Expand Down

0 comments on commit 2331ac7

Please sign in to comment.