From 9a228336c2f0c8a1c2d678da59017be6eba9ec52 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Wed, 28 Sep 2016 09:55:04 +0200 Subject: [PATCH] Added stop/fail message as requested in #1914 --- Duplicati/Library/Main/Controller.cs | 15 +++++++++++---- Duplicati/Library/Main/Strings.cs | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Duplicati/Library/Main/Controller.cs b/Duplicati/Library/Main/Controller.cs index e7a6ecc11..07605c631 100644 --- a/Duplicati/Library/Main/Controller.cs +++ b/Duplicati/Library/Main/Controller.cs @@ -89,11 +89,16 @@ namespace Duplicati.Library.Main private void OperationRunning(bool isRunning) { if (m_options != null && !m_options.AllowSleep && !Duplicati.Library.Utility.Utility.IsClientLinux) + { try { Win32.SetThreadExecutionState(Win32.EXECUTION_STATE.ES_CONTINUOUS | (isRunning ? Win32.EXECUTION_STATE.ES_SYSTEM_REQUIRED : 0)); } - catch { } //TODO: Report this somehow + catch (Exception ex) + { + Logging.Log.WriteMessage("Failed to set sleep prevention", Logging.LogMessageType.Warning, ex); + } + } } /// @@ -352,7 +357,6 @@ namespace Duplicati.Library.Main using(new Logging.Timer(string.Format("Running {0}", result.MainOperation))) { SetupCommonOptions(result, ref paths, ref filter); - OperationRunning(true); method(result); @@ -360,18 +364,21 @@ namespace Duplicati.Library.Main result.SetDatabase(null); OnOperationComplete(result); + + Library.Logging.Log.WriteMessage(Strings.Controller.CompletedOperationMessage(m_options.MainAction), Logging.LogMessageType.Information); + return result; } } catch (Exception ex) { - Logging.Log.WriteMessage("Terminated with error: " + ex.Message, Duplicati.Library.Logging.LogMessageType.Error, ex); - OnOperationComplete(ex); try { (result as BasicResults).OperationProgressUpdater.UpdatePhase(OperationPhase.Error); } catch { } + Library.Logging.Log.WriteMessage(Strings.Controller.FailedOperationMessage(m_options.MainAction, ex.Message), Logging.LogMessageType.Error, ex); + throw; } finally diff --git a/Duplicati/Library/Main/Strings.cs b/Duplicati/Library/Main/Strings.cs index d3f75c27c..eb324d360 100644 --- a/Duplicati/Library/Main/Strings.cs +++ b/Duplicati/Library/Main/Strings.cs @@ -20,6 +20,8 @@ namespace Duplicati.Library.Main.Strings public static string UnsupportedSizeValue(string optionname, string value) { return LC.L(@"The value ""{1}"" supplied to --{0} does not represent a valid size", optionname, value); } public static string UnsupportedTimeValue(string optionname, string value) { return LC.L(@"The value ""{1}"" supplied to --{0} does not represent a valid time", optionname, value); } public static string StartingOperationMessage(OperationMode operationname) { return LC.L(@"The operation {0} has started", operationname); } + public static string CompletedOperationMessage(OperationMode operationname) { return LC.L(@"The operation {0} has completed", operationname); } + public static string FailedOperationMessage(OperationMode operationname, string errormessage) { return LC.L(@"The operation {0} has failed with error: {1}", operationname, errormessage); } public static string InvalidPathError(string path, string message) { return LC.L(@"Invalid path: ""{0}"" ({1})", path, message); } public static string FailedForceLocaleError(string exMsg) { return LC.L(@"Failed to apply 'force-locale' setting. Please try to update .NET-Framework. Exception was: ""{0}"" ", exMsg); } }