Update log files are now copied to application folder.

pull/6/head
kay.one 13 years ago
parent ff8d837380
commit b74ef12a4c

@ -22,6 +22,7 @@ namespace NzbDrone.Common
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 @@ namespace NzbDrone.Common
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 @@ namespace NzbDrone.Common
{
return Path.Combine(enviromentProvider.GetUpdateClientFolder(), UPDATE_CLIENT_EXE);
}
public static string GetSandboxLogFolder(this EnviromentProvider enviromentProvider)
{
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_LOG_FOLDER_NAME);
}
}
}

@ -15,7 +15,9 @@ namespace NzbDrone.Update.Test
{
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 @@ namespace NzbDrone.Update.Test
Mocker.GetMock<ProcessProvider>()
.Verify(c => c.Start(TARGET_FOLDER + "nzbdrone.exe"), Times.Once());
}
}
}

@ -46,6 +46,24 @@ namespace NzbDrone.Update
{
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 @@ namespace NzbDrone.Update
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}";

Loading…
Cancel
Save