diff options
Diffstat (limited to 'Emby.Server.Implementations/AppBase')
| -rw-r--r-- | Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs | 18 | ||||
| -rw-r--r-- | Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | 6 |
2 files changed, 12 insertions, 12 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 59c7c655f..90b43bc59 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.AppBase Logger.LogInformation("Saving system configuration"); var path = CommonApplicationPaths.SystemConfigurationFilePath; - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_configurationSyncLock) { @@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.AppBase && !string.Equals(CommonConfiguration.CachePath ?? string.Empty, newPath)) { // Validate - if (!FileSystem.DirectoryExists(newPath)) + if (!Directory.Exists(newPath)) { throw new FileNotFoundException(string.Format("{0} does not exist.", newPath)); } @@ -209,8 +209,7 @@ namespace Emby.Server.Implementations.AppBase protected void EnsureWriteAccess(string path) { var file = Path.Combine(path, Guid.NewGuid().ToString()); - - FileSystem.WriteAllText(file, string.Empty); + File.WriteAllText(file, string.Empty); FileSystem.DeleteFile(file); } @@ -246,13 +245,14 @@ namespace Emby.Server.Implementations.AppBase private object LoadConfiguration(string path, Type configurationType) { - try + if (!File.Exists(path)) { - return XmlSerializer.DeserializeFromFile(configurationType, path); + return Activator.CreateInstance(configurationType); } - catch (FileNotFoundException) + + try { - return Activator.CreateInstance(configurationType); + return XmlSerializer.DeserializeFromFile(configurationType, path); } catch (IOException) { @@ -293,7 +293,7 @@ namespace Emby.Server.Implementations.AppBase _configurations.AddOrUpdate(key, configuration, (k, v) => configuration); var path = GetConfigurationFile(key); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_configurationSyncLock) { diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index ee6da95fe..3faad76e7 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.AppBase // Use try/catch to avoid the extra file system lookup using File.Exists try { - buffer = fileSystem.ReadAllBytes(path); + buffer = File.ReadAllBytes(path); configuration = xmlSerializer.DeserializeFromBytes(type, buffer); } @@ -48,10 +48,10 @@ namespace Emby.Server.Implementations.AppBase // If the file didn't exist before, or if something has changed, re-save if (buffer == null || !buffer.SequenceEqual(newBytes)) { - fileSystem.CreateDirectory(fileSystem.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); // Save it after load in case we got new items - fileSystem.WriteAllBytes(path, newBytes); + File.WriteAllBytes(path, newBytes); } return configuration; |
