/// <summary> /// /// </summary> private static void UpgradeSettings() { if (Settings.LastUpgradeVersion == 0) { // Server port was modified on this version due to protocal differences. if (Settings.ServerPort == 12341) { Settings.ServerPort = 12340; } } if (Settings.LastUpgradeVersion < 100000612) { // Copy over manifests folder from old storage path. string SrcPath = Path.Combine(Settings.StoragePath, "Manifests"); string DstPath = Path.Combine(AppDataDir, "Manifests"); if (Directory.Exists(SrcPath)) { if (!Directory.Exists(DstPath)) { Directory.CreateDirectory(DstPath); } foreach (string SrcFile in Directory.GetFiles(SrcPath)) { string DstFile = Path.Combine(DstPath, SrcFile.Substring(SrcPath.Length + 1)); if (!File.Exists(DstFile)) { File.Copy(SrcFile, DstFile); } } } // Storage settings need to use old paths. if (Settings.StoragePath.Length > 0) { Settings.StorageLocations.Add(new StorageLocation { Path = Settings.StoragePath, MaxSize = Settings.StorageMaxSize }); } } Settings.LastUpgradeVersion = AppVersion.VersionNumber; }
/// <summary> /// </summary> private static void InitSettings() { string AppDir = AppDataDir; SettingsPath = Path.Combine(AppDir, "Config.json"); SettingsBase.Load(SettingsPath, out Settings); if (Settings.LastUpgradeVersion < AppVersion.VersionNumber) { Logger.Log(LogLevel.Info, LogCategory.Main, "InitSettings: Upgrading settings."); UpgradeSettings(); } if (Settings.LastUpgradeVersion < 100000613) { // Copy over manifests folder from old storage path. string SrcPath = Path.Combine(Settings.StoragePath, "Manifests"); string DstPath = Path.Combine(AppDataDir, "Manifests"); if (Directory.Exists(SrcPath)) { if (!Directory.Exists(DstPath)) { Directory.CreateDirectory(DstPath); } foreach (string SrcFile in Directory.GetFiles(SrcPath)) { string DstFile = Path.Combine(DstPath, SrcFile.Substring(SrcPath.Length + 1)); if (!File.Exists(DstFile)) { File.Copy(SrcFile, DstFile); } } } } Settings.Save(SettingsPath); ApplySettings(); }