https://discord.umbraco.com logo
#help-with-umbraco
uSync - Media Picker start nodes - create and pick on deployment
# help-with-umbraco
s

siempresteve

09/28/2023, 7:36 AM
I'm sure I've seen this solved elsewhere if someone can point me in the right direction? In local dev environment I create a new media root folder to match my new media picker. On deployment usync runs but obviously that media folder guid doesn't match and there's no folder yet either. If I manually update it then when it runs next time it wipes the new value. Basically I want to have it so when usync runs if the media folder doesn't exist it creates it automatically for me (same name) link the starting node and then doesn't overwrite it again. I can see this config serliazer is something on the way to this but if the media folder doesn't exist how do I create it first? https://github.com/KevinJump/uSync/blob/v11/dev/uSync.Community.DataTypeSerializers/CoreTypes/MediaPickerConfigSerializer.cs
k

kevinjump

09/28/2023, 8:24 AM
humm 🤔 you could use the "createOnly" setting on media, so any media folders on your local would be created only (not updated if they exist) on the deployed site. https://docs.jumoo.co.uk/usync/uSync/reference/handlers#handler-settings but that might result in to many folders so you could couple it with the "Include" or "Exclude" rules so only certain path's would be created
but I think its probibly a good candidate for us extending uSync here - we could do something that creates the folders i think.
you could listen for the
uSyncImportingItemNotification
and when its a datatype look for the path, and if it doesn't exist create it but that would require some custom code,
s

siempresteve

09/28/2023, 9:23 AM
I'm happy with custom code - I can just have something that fires after usync creates / updates the datatype and just creates a folder and links it. That would be fine with me.
Sorry to be dumb here - would I just be best hooking into an event that usync has just run the settings update (is there such a thing?).
k

kevinjump

09/28/2023, 9:31 AM
yeah - for v10+ notification handlers - (like this one https://gist.github.com/KevinJump/4abd68d19a429aa1ad1329dfdfe4240c) - you can do it at a number of points : e.g - uSyncImportingItemNotification - before the item is imports - uSyncImportedItemNotification - after an item is imported - uSyncImportStartingNotification - before the whole process starts - uSyncImportCompletedNotification - after the whole import process has completed
s

siempresteve

09/28/2023, 1:20 PM
👍 thanks Kevin.