aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Plugins/BasePlugin.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-23 19:49:13 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-23 19:49:13 -0400
commit2af3ec43d52d44ff7b456de35e45b12413edcf9d (patch)
tree0870f82ea5a2636f84635201433deab8b89143f4 /MediaBrowser.Common/Plugins/BasePlugin.cs
parentabc5a2eabd005c0032687ea051c4285f32258635 (diff)
make common project portable
Diffstat (limited to 'MediaBrowser.Common/Plugins/BasePlugin.cs')
-rw-r--r--MediaBrowser.Common/Plugins/BasePlugin.cs40
1 files changed, 15 insertions, 25 deletions
diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs
index 89ebeb6db..95e076096 100644
--- a/MediaBrowser.Common/Plugins/BasePlugin.cs
+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs
@@ -61,8 +61,17 @@ namespace MediaBrowser.Common.Plugins
AssemblyFileName = assemblyFileName;
Version = assemblyVersion;
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>
@@ -94,7 +103,7 @@ namespace MediaBrowser.Common.Plugins
// Ensure it's been lazy loaded
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);
}
- catch (DirectoryNotFoundException)
- {
- return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
- }
- catch (FileNotFoundException)
- {
- return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
- }
catch
{
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
@@ -183,10 +184,6 @@ namespace MediaBrowser.Common.Plugins
}
/// <summary>
- /// The _data folder path
- /// </summary>
- private string _dataFolderPath;
- /// <summary>
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed
/// </summary>
/// <value>The data folder path.</value>
@@ -194,16 +191,9 @@ namespace MediaBrowser.Common.Plugins
{
get
{
- if (_dataFolderPath == null)
- {
- // Give the folder name the same name as the config file name
- // We can always make this configurable if/when needed
- _dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName));
-
- Directory.CreateDirectory(_dataFolderPath);
- }
-
- return _dataFolderPath;
+ // Give the folder name the same name as the config file name
+ // We can always make this configurable if/when needed
+ return Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName));
}
}
@@ -230,7 +220,7 @@ namespace MediaBrowser.Common.Plugins
{
lock (_configurationSaveLock)
{
- Directory.CreateDirectory(Path.GetDirectoryName(ConfigurationFilePath));
+ _directoryCreateFn(Path.GetDirectoryName(ConfigurationFilePath));
XmlSerializer.SerializeToFile(Configuration, ConfigurationFilePath);
}