|
|
@ -61,8 +61,17 @@ namespace MediaBrowser.Common.Plugins
|
|
|
|
AssemblyFileName = assemblyFileName;
|
|
|
|
AssemblyFileName = assemblyFileName;
|
|
|
|
Version = assemblyVersion;
|
|
|
|
Version = assemblyVersion;
|
|
|
|
Id = assemblyId;
|
|
|
|
Id = assemblyId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Func<string, DateTime> _dateModifiedFn;
|
|
|
|
|
|
|
|
private Action<string> _directoryCreateFn;
|
|
|
|
|
|
|
|
public void SetStartupInfo(bool isFirstRun, Func<string, DateTime> dateModifiedFn, Action<string> directoryCreateFn)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IsFirstRun = isFirstRun;
|
|
|
|
|
|
|
|
|
|
|
|
IsFirstRun = !File.Exists(ConfigurationFilePath);
|
|
|
|
// hack alert, until the .net core transition is complete
|
|
|
|
|
|
|
|
_dateModifiedFn = dateModifiedFn;
|
|
|
|
|
|
|
|
_directoryCreateFn = directoryCreateFn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -94,7 +103,7 @@ namespace MediaBrowser.Common.Plugins
|
|
|
|
// Ensure it's been lazy loaded
|
|
|
|
// Ensure it's been lazy loaded
|
|
|
|
var config = Configuration;
|
|
|
|
var config = Configuration;
|
|
|
|
|
|
|
|
|
|
|
|
return File.GetLastWriteTimeUtc(ConfigurationFilePath);
|
|
|
|
return _dateModifiedFn(ConfigurationFilePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -147,14 +156,6 @@ namespace MediaBrowser.Common.Plugins
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (TConfigurationType)XmlSerializer.DeserializeFromFile(typeof(TConfigurationType), path);
|
|
|
|
return (TConfigurationType)XmlSerializer.DeserializeFromFile(typeof(TConfigurationType), path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (DirectoryNotFoundException)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (FileNotFoundException)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
|
|
|
|
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
|
|
|
@ -182,10 +183,6 @@ namespace MediaBrowser.Common.Plugins
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// The _data folder path
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private string _dataFolderPath;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed
|
|
|
|
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -193,17 +190,10 @@ namespace MediaBrowser.Common.Plugins
|
|
|
|
public string DataFolderPath
|
|
|
|
public string DataFolderPath
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get
|
|
|
|
get
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_dataFolderPath == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Give the folder name the same name as the config file name
|
|
|
|
// Give the folder name the same name as the config file name
|
|
|
|
// We can always make this configurable if/when needed
|
|
|
|
// We can always make this configurable if/when needed
|
|
|
|
_dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName));
|
|
|
|
return Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName));
|
|
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(_dataFolderPath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return _dataFolderPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -230,7 +220,7 @@ namespace MediaBrowser.Common.Plugins
|
|
|
|
{
|
|
|
|
{
|
|
|
|
lock (_configurationSaveLock)
|
|
|
|
lock (_configurationSaveLock)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(ConfigurationFilePath));
|
|
|
|
_directoryCreateFn(Path.GetDirectoryName(ConfigurationFilePath));
|
|
|
|
|
|
|
|
|
|
|
|
XmlSerializer.SerializeToFile(Configuration, ConfigurationFilePath);
|
|
|
|
XmlSerializer.SerializeToFile(Configuration, ConfigurationFilePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|