3

Sitecore advises that you should sync a bucket after you delete an item from it.

I have a mass import process that adds/updates/deletes items. The bucket contains hundreds of thousands of items and I would prefer not to do a full bucket sync at the end.

I've decompiled the Buckets code and it looks like syncing just moves unbucketable items to the root and deletes empty folders. There is a IsSynced flag in the pipeline args but I don't think it's used for anything.

So my questions are:

Is the advice to sync after deleting items just a housekeeping thing (cleaning up empty folders), or does it have some material impact on the functionality of the bucket?

Could I just implement some logic to clean up the ancestor folders at the point that I delete an item, or is there some other magic that the sync process does that I'd be missing?

1

I can find no magic ;-)

While the bucket sync takes care of a great many things, in your specific case (deleting a bucket item), it really is just a cleanup. The hosting folder will get deleted if there are no other child items in the folder.

    if (!this.ShouldDeleteInCreationOfBucket(current) || current.GetChildren(ChildListOptions.SkipSorting).Any<Item>())
      return;
    current.Delete();

The ShouldDeleteInCreationOfBucket call really just tests if the current items being processed is a BucketFolder. So to paraphrase "if this is not a BucketFolder or if there are .Any children present, return. Otherwise delete the item (BucketFolder without children)".

You could implement similar logic on the delete event; but it really is just a bit of housekeeping that I can't see breaking any stuff even if you don't.

For reference, when deleting via the UI, the event item:bucketing:deleting will get raised. I don't see this happening in a programmatic item delete.

  • Pretty much what I figured, but need a second opinion. thanks Mark – Martin Davies Jul 17 '17 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.