KevinJump / uSync-Legacy

uSync for Umbraco 4/6 - bits of the database to disk, and stuff like that
https://jumoo.co.uk/usync/
Mozilla Public License 2.0
75 stars 64 forks source link

Adding root settings to handler groups #147

Closed dinc5150 closed 6 years ago

dinc5150 commented 7 years ago

Hi Kevin,

I use handler groups for defining different setups between my dev, staging and live sites and it works really well. One thing I would love to be able to do is disable the "Import at startup" event on the live site (mainly to reduce boot time). I know that I can just disable it in the config on the live site, but it gets overridden on deploy.

So wanted to know your thoughts about adding a Import=false (and possibly other settings) as an attribute on the handlers or if you had better suggestions before I start looking at putting together a pull request for this.

KevinJump commented 7 years ago

Hi yeah - i usually transform the Import setting as part of deploy, so something like

<Import xdt:Transform="Replace">false</Import> in a usyncbackoffice.release.config

but applying the transform file does depend on the deployment tool you are using.

there are some attribute based things already on the handlers (See https://github.com/KevinJump/uSync/issues/59#issuecomment-238525487 ) but that is more individual handlers being called on the import,export or save events - this doesn't discriminate between startup import and any other imports

If i was adding it I would think adding this to the handler group would make sense

things i thing would need some refactoring...

  1. The main import function doesn't actually have a sense of if it is being ran at start up or just because someone asked it to. ImportAll is called from the event handler - (https://github.com/KevinJump/uSync/blob/Dev-v7_4/Jumoo.uSync.BackOffice/uSyncApplicationEventHandler.cs#L69)

  2. So Probably in ImportAll a flag could be passed for startup, and then the Handler Group could be checked here to see if import at startup is enabled on it ? (https://github.com/KevinJump/uSync/blob/Dev-v7_4/Jumoo.uSync.BackOffice/uSyncBackOfficeContext.cs#L115)

Changing the signature of ImportAll would be an API change so would require a major version change using SemVersion - so we would just have to be careful and maybe put an additional function in to make it only an minor change. but that is where i would look.

dinc5150 commented 7 years ago

Thanks for the quick response Kevin! Yes, I did consider using config transforms on the config file, but not doing transforms on anything other than the web.config files at the moment.

I currently do restrict what gets imported into the live site, but it would be nice to have the option to only do it when manually importing.

Thanks for pointing me in the right direction, I'll take a look and see whats involved.

Thanks for the help!

KevinJump commented 6 years ago

Added code to read values from the web.config, so you can use them to override the ones in the usyncbackoffice.config file.

in the appsettings section

<add key="uSync.Import" value="false"/>
<add key="uSync.ExportAtStartup" value="false"/>
<add key="uSync.ExportOnSave" value="false"/>
<add key="uSync.HandlerGroup" value="default"/>

Will be in next release.