2018-10-05 23:10:39 -04:00
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Application.Migration
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// helps facilitate the migration of configs from one version and or location
|
|
|
|
|
/// to another
|
|
|
|
|
/// </summary>
|
|
|
|
|
class ConfigurationMigration
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// moves existing configs from the root folder into a configs folder
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void MoveConfigFolder10518(ILogger log)
|
|
|
|
|
{
|
|
|
|
|
string currentDirectory = Utilities.OperatingDirectory;
|
|
|
|
|
|
|
|
|
|
// we don't want to do this for migrations or tests where the
|
|
|
|
|
// property isn't initialized or it's wrong
|
|
|
|
|
if (currentDirectory != null)
|
|
|
|
|
{
|
|
|
|
|
string configDirectory = Path.Join(currentDirectory, "Configuration");
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(configDirectory))
|
|
|
|
|
{
|
2018-10-12 22:28:22 -04:00
|
|
|
|
log?.WriteDebug($"Creating directory for configs {configDirectory}");
|
2018-10-05 23:10:39 -04:00
|
|
|
|
Directory.CreateDirectory(configDirectory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var configurationFiles = Directory.EnumerateFiles(currentDirectory, "*.json")
|
|
|
|
|
.Select(f => f.Split(Path.DirectorySeparatorChar).Last())
|
|
|
|
|
.Where(f => f.Count(c => c == '.') == 1);
|
|
|
|
|
|
|
|
|
|
foreach (var configFile in configurationFiles)
|
|
|
|
|
{
|
2018-10-12 22:28:22 -04:00
|
|
|
|
log?.WriteDebug($"Moving config file {configFile}");
|
2018-10-05 23:10:39 -04:00
|
|
|
|
string destinationPath = Path.Join("Configuration", configFile);
|
|
|
|
|
if (!File.Exists(destinationPath))
|
|
|
|
|
{
|
|
|
|
|
File.Move(configFile, destinationPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-06 12:47:14 -04:00
|
|
|
|
|
|
|
|
|
if (!File.Exists(Path.Join("Database", "Database.db")) &&
|
|
|
|
|
File.Exists("Database.db"))
|
|
|
|
|
{
|
2018-10-12 22:28:22 -04:00
|
|
|
|
log?.WriteDebug("Moving database file");
|
2018-10-06 12:47:14 -04:00
|
|
|
|
File.Move("Database.db", Path.Join("Database", "Database.db"));
|
|
|
|
|
}
|
2018-10-05 23:10:39 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-09 16:35:13 -05:00
|
|
|
|
|
|
|
|
|
public static void ModifyLogPath020919(SharedLibraryCore.Configuration.ServerConfiguration config)
|
|
|
|
|
{
|
|
|
|
|
if (config.ManualLogPath.IsRemoteLog())
|
|
|
|
|
{
|
|
|
|
|
config.GameLogServerUrl = new Uri(config.ManualLogPath);
|
|
|
|
|
config.ManualLogPath = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-05 23:10:39 -04:00
|
|
|
|
}
|
|
|
|
|
}
|