Merge pull request #4339 from BaronGreenback/PluginConfigSave

Making default Plugin configurations accessible when developing.
This commit is contained in:
Joshua M. Boniface 2020-11-20 12:34:38 -05:00 committed by GitHub
commit d2cef78db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -247,7 +247,23 @@ namespace MediaBrowser.Common.Plugins
} }
catch catch
{ {
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType)); var config = (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
SaveConfiguration(config);
return config;
}
}
/// <summary>
/// Saves the current configuration to the file system.
/// </summary>
/// <param name="config">Configuration to save.</param>
public virtual void SaveConfiguration(TConfigurationType config)
{
lock (_configurationSaveLock)
{
_directoryCreateFn(Path.GetDirectoryName(ConfigurationFilePath));
XmlSerializer.SerializeToFile(config, ConfigurationFilePath);
} }
} }
@ -256,12 +272,7 @@ namespace MediaBrowser.Common.Plugins
/// </summary> /// </summary>
public virtual void SaveConfiguration() public virtual void SaveConfiguration()
{ {
lock (_configurationSaveLock) SaveConfiguration(Configuration);
{
_directoryCreateFn(Path.GetDirectoryName(ConfigurationFilePath));
XmlSerializer.SerializeToFile(Configuration, ConfigurationFilePath);
}
} }
/// <inheritdoc /> /// <inheritdoc />
@ -274,7 +285,7 @@ namespace MediaBrowser.Common.Plugins
Configuration = (TConfigurationType)configuration; Configuration = (TConfigurationType)configuration;
SaveConfiguration(); SaveConfiguration(Configuration);
ConfigurationChanged?.Invoke(this, configuration); ConfigurationChanged?.Invoke(this, configuration);
} }