1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-25 09:12:17 +00:00

Update log files are now copied to application folder.

This commit is contained in:
kay.one 2011-11-20 18:13:10 -08:00
parent ff8d837380
commit b74ef12a4c
3 changed files with 34 additions and 1 deletions

View file

@ -22,6 +22,7 @@ public static class PathExtentions
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\";
private const string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
private const string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update\\";
public const string UPDATE_LOG_FOLDER_NAME = "UpdateLogs\\";
public static string NormalizePath(this string path)
{
@ -94,6 +95,11 @@ public static string GetCacheFolder(this EnviromentProvider enviromentProvider)
return Path.Combine(enviromentProvider.GetWebRoot(), "Cache");
}
public static string GetUpdateLogFolder(this EnviromentProvider enviromentProvider)
{
return Path.Combine(enviromentProvider.ApplicationPath, UPDATE_LOG_FOLDER_NAME);
}
public static string GetUpdateSandboxFolder(this EnviromentProvider enviromentProvider)
{
return Path.Combine(enviromentProvider.SystemTemp, UPDATE_SANDBOX_FOLDER_NAME);
@ -118,5 +124,10 @@ public static string GetUpdateClientExePath(this EnviromentProvider enviromentPr
{
return Path.Combine(enviromentProvider.GetUpdateClientFolder(), UPDATE_CLIENT_EXE);
}
public static string GetSandboxLogFolder(this EnviromentProvider enviromentProvider)
{
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_LOG_FOLDER_NAME);
}
}
}

View file

@ -15,7 +15,9 @@ class UpdateProviderStartFixture : TestBase
{
private const string UPDATE_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone\";
private const string BACKUP_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone_backup\";
private const string SANDBOX_LOG_FOLDER = @"C:\Temp\nzbdrone_update\UpdateLogs\";
private const string TARGET_FOLDER = @"C:\NzbDrone\";
private const string UPDATE_LOG_FOLDER = @"C:\NzbDrone\UpdateLogs\";
Mock<EnviromentProvider> _enviromentProvider;
@ -239,5 +241,7 @@ private void VerifyProcessRestart()
Mocker.GetMock<ProcessProvider>()
.Verify(c => c.Start(TARGET_FOLDER + "nzbdrone.exe"), Times.Once());
}
}
}

View file

@ -46,6 +46,24 @@ public static void Main(string[] args)
{
logger.FatalException("An error has occurred while applying update package.", e);
}
TransferUpdateLogs();
}
private static void TransferUpdateLogs()
{
try
{
var enviromentProvider = new EnviromentProvider();
var diskProvider = new DiskProvider();
logger.Info("Copying log tiles to application directory.");
diskProvider.CopyDirectory(enviromentProvider.GetSandboxLogFolder(), enviromentProvider.GetUpdateLogFolder());
}
catch (Exception e)
{
logger.FatalException("Can't copy upgrade log files to target folder", e);
}
}
private static void InitLoggers()
@ -57,7 +75,7 @@ private static void InitLoggers()
var lastUpgradeLog = new FileTarget();
lastUpgradeLog.AutoFlush = true;
lastUpgradeLog.ConcurrentWrites = false;
lastUpgradeLog.FileName = Path.Combine("UpgradeLog", DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
lastUpgradeLog.FileName = Path.Combine(PathExtentions.UPDATE_LOG_FOLDER_NAME, DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
lastUpgradeLog.KeepFileOpen = false;
lastUpgradeLog.Layout = "${longdate} - ${logger}: ${message} ${exception}";