DanDiplo / Diplo.DictionaryEditor

An Umbraco package that creates a custom section for editing Dictionary values in Umbraco. It allows easy editing of all dictionary items and also allows the dictionary to be exported and imported in CSV format.
https://www.diplo.co.uk/blog/web-development/diplo-dictionary-editor-for-umbraco/
1 stars 4 forks source link

Problem using in combination with uSync #10

Open gordonsaxby opened 3 years ago

gordonsaxby commented 3 years ago

We use uSync for site to site transfers of DataTypes, etc.

It appears that if we do an import and then the site is restarted (IIS), the import is lost and the uSync values are re-imported.

However, if we do an import, then manually go to the Dictionary section and select / save each top level item within the Dictionary section, the imported data survives a restart. The action of Saving the top level Dictionary items updates the uSync files.

Is the import routine not updating something (in Umbraco / DB), so uSync thinks it needs to import its data when the site restarts?

DanDiplo commented 3 years ago

Hi Gordon. My package directly updates the Umbraco database, so it bypasses the Umbraco services (as these aren't made for bulk actions) so it may be something to do with that. Maybe you need to ask Kevin Jump if he has any idea as I'm not sure myself how uSync determines this?

KevinJump commented 3 years ago

Hi,

uSync is using the Umbraco LocalizationService to get a copy of what umbraco thinks the dictionary values are - so at startup they will be compared, but i don't think that is the issue.

the issue will probably be when the values are updated in the database directly the save events for dictionary items will not be fired so uSync won't write the new values to disk.

When the site restarts the old values are still in the usync folder, so it writes them back thinking they are the ones you want syncing.

so either 1) there needs to be some form of save event fired after the bulk export so uSync can update the values on disk. 2) you could switch the dictionary handler in usync not to sync existing dictionary items (only new ones). (see docs https://docs.jumoo.co.uk/uSync/v8/ContentEdition/dictionaryHandler/)

only real problem with number 2 is it masks the issue that your up to date dictionary items haven't been saved into the usync folder and if you move to another installation they will all be out of date.

DanDiplo commented 3 years ago

Hi @KevinJump That makes sense and it was along the lines of what I suspected. Would one save event work (as a trigger) or would I need to raise a save event for each dictionary item? As I say, I avoided the Umbraco services for a good reason - they were just glacially slow with mass updates. I think when I get around to v8 version I'll just have to go with those to avoid these kind of issues.

KevinJump commented 3 years ago

i think for uSync you would need to trigger one save for each root item (it will then save down the tree) - there is an uSync event to trigger the export to, but you would likely want that in a intermediate library, so you would have no dependencies.