diff --git a/Duplicati/CommandLine/ConsoleLogTarget.cs b/Duplicati/CommandLine/ConsoleLogTarget.cs deleted file mode 100644 index 297ad1c2d..000000000 --- a/Duplicati/CommandLine/ConsoleLogTarget.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2018, The Duplicati Team -// http://www.duplicati.com, info@duplicati.com -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.IO; -using Duplicati.Library.Logging; -using Duplicati.Library.Utility; - -namespace Duplicati.CommandLine -{ - /// - /// Log output handler for the console - /// - public class ConsoleLogTarget : Library.Logging.ILogDestination - { - /// - /// The stdout stream - /// - private readonly TextWriter m_stdout; - /// - /// The stderr stream - /// - private readonly TextWriter m_stderr; - /// - /// The default log level - /// - private readonly LogMessageType m_level; - /// - /// The filter, if any - /// - private readonly IFilter m_filter; - - /// - /// Initializes a new instance of the class. - /// - /// The stdout stream. - /// The stderr stream. - /// The minimum log level to consider. - /// The log filter, if any. - public ConsoleLogTarget(TextWriter stdout, TextWriter stderr, LogMessageType level, string logfilter) - { - m_stdout = stdout; - m_stderr = stderr; - m_level = level; - m_filter = FilterExpression.ParseLogFilter(logfilter); - } - - /// - /// Writes the message to stdout or stderr. - /// - /// The entry to write. - public void WriteMessage(LogEntry entry) - { - var found = m_filter.Matches(entry.FilterTag, out var result, out var match); - // If there is a filter match, use that - if (found) - { - if (!result) - return; - - if (entry.Level == LogMessageType.Error) - m_stderr.WriteLine(entry); - else - m_stdout.WriteLine(entry); - } - else - { - // Otherwise, filter by log-level - if (entry.Level < m_level) - return; - } - - if (entry.Level == LogMessageType.Error) - m_stderr.WriteLine(entry.FormattedMessage); - else - m_stdout.WriteLine(entry.FormattedMessage); - - } - } -} diff --git a/Duplicati/CommandLine/Strings.cs b/Duplicati/CommandLine/Strings.cs index 5db8812c5..5f47b9272 100644 --- a/Duplicati/CommandLine/Strings.cs +++ b/Duplicati/CommandLine/Strings.cs @@ -31,6 +31,13 @@ namespace Duplicati.CommandLine.Strings { public static string QuietConsoleOptionLong { get { return LC.L(@"If this option is set, progress reports and other messages that would normally go to the console will be redirected to the log."); } } public static string QuietConsoleOptionShort { get { return LC.L(@"Disable console output"); } } public static string SkippingSourceArgumentsOnNonBackupOperation { get { return @"The --source argument was specified in the parameter file, but the current operation is not a backup operation, so the argument is ignored"; } } + + + // ReSharper disable once UnusedMember.Global + // This is a placeholder message that is intended to be used with the code + // for each error and log message. The idea is that the commandline will + // use the code to provide a link to the forum, searching for the code, + // such that it is easy to maintain a list of help links. public static string YouMayGetMoreHelpHere(string url) { return LC.L(@"This link may provide additional information: {0}", url); } } } diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/CocoaRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/CocoaRunner.cs index 413296fa2..bc478a868 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/CocoaRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/CocoaRunner.cs @@ -68,11 +68,6 @@ namespace Duplicati.GUI.TrayIcon // Do nothing. Implementation needed for IMenuItem interface. } - public void SetEnabled(bool isEnabled) - { - m_item.Enabled = isEnabled; - } - public void SetDefault(bool isDefault) { // Do nothing. Implementation needed for IMenuItem interface. diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs index a1272f8db..ff067bc0c 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs @@ -1,22 +1,22 @@ -// Copyright (C) 2015, The Duplicati Team -// http://www.duplicati.com, info@duplicati.com -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Copyright (C) 2015, The Duplicati Team +// http://www.duplicati.com, info@duplicati.com +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #if __MonoCS__ || __WindowsGTK__ || ENABLE_GTK using System; -using System.Collections.Generic; +using System.Collections.Generic; using Duplicati.Library.Common; using Gdk; using Gtk; @@ -155,14 +155,9 @@ namespace Duplicati.GUI.TrayIcon ((ImageMenuItem) m_item).Image = GetIcon(icon); } - public void SetEnabled(bool isEnabled) - { - m_item.Sensitive = isEnabled; - } - public void SetDefault(bool isDefault) { - // Do nothing. Implementation needed for TrayIconBase interface. + // Do nothing. Implementation needed for TrayIconBase interface. } } @@ -232,17 +227,6 @@ namespace Duplicati.GUI.TrayIcon } } - public static Gtk.Image ImageToGtk(System.Drawing.Image image) - { - using (var stream = new System.IO.MemoryStream()) - { - image.Save(stream, System.Drawing.Imaging.ImageFormat.Png); - stream.Position = 0; - Gtk.Image img = new Gtk.Image(stream); - return img; - } - } - protected static string GetTrayIconFilename(TrayIcons icon) { switch (icon) @@ -304,10 +288,10 @@ namespace Duplicati.GUI.TrayIcon return _images[icon]; } - protected override void SetIcon(TrayIcons icon) - { - m_trayIcon.Pixbuf = GetIcon(icon); - } + protected override void SetIcon(TrayIcons icon) + { + m_trayIcon.Pixbuf = GetIcon(icon); + } protected override void SetMenu (IEnumerable items) diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs index 9bd9b4a19..6b74095ba 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; -using Duplicati.Library.Common.IO; +using Duplicati.Library.Common.IO; using Duplicati.Server.Serialization; using Duplicati.Server.Serialization.Interface; @@ -27,10 +27,6 @@ namespace Duplicati.GUI.TrayIcon public string Endpoint; public Dictionary Query; - public BackgroundRequest() - { - } - public BackgroundRequest(string method, string endpoint, Dictionary query) { this.Method = method; diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs index 991e68f86..97faf58c1 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs @@ -21,8 +21,8 @@ using System.Linq; using System.IO; using System.Threading.Tasks; using CoCoL; -using Duplicati.Library.Common; - +using Duplicati.Library.Common; + namespace Duplicati.GUI.TrayIcon { public class RumpsRunner : TrayIconBase @@ -75,15 +75,6 @@ namespace Duplicati.GUI.TrayIcon } } - public void SetEnabled(bool isEnabled) - { - if (this.Enabled != isEnabled) - { - this.Enabled = isEnabled; - m_parent.UpdateMenu(this); - } - } - public void SetDefault(bool isDefault) { if (this.Default != isDefault) @@ -164,9 +155,9 @@ namespace Duplicati.GUI.TrayIcon var ch = ChannelManager.CreateChannel(); m_toRumps = ch.AsWriteOnly(); - WriteChannel(m_rumpsProcess.StandardInput, ch.AsReadOnly()); - #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - ReadChannel(m_rumpsProcess.StandardOutput); + WriteChannel(m_rumpsProcess.StandardInput, ch.AsReadOnly()); + #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + ReadChannel(m_rumpsProcess.StandardOutput); ReadChannel(m_rumpsProcess.StandardError); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed @@ -313,7 +304,7 @@ namespace Duplicati.GUI.TrayIcon if (m_rumpsProcess != null && !m_rumpsProcess.HasExited) { if (m_toRumps != null) - { + { m_toRumps.WriteNoWait(JsonConvert.SerializeObject(new { Action = "shutdown" })); m_toRumps.Dispose(); m_toRumps = null; diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs index 1a96389c7..47734f84e 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs @@ -56,7 +56,6 @@ namespace Duplicati.GUI.TrayIcon public interface IMenuItem { void SetDefault(bool isDefault); - void SetEnabled(bool isEnabled); void SetIcon(MenuIcons icon); void SetText(string text); } diff --git a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs index 41b4bfa29..98ee79afd 100644 --- a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs +++ b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using Duplicati.Library.Common.IO; +using Duplicati.Library.Common.IO; using Duplicati.Library.Interface; using Newtonsoft.Json; using System; diff --git a/Duplicati/Library/Backend/OAuthHelper/JSONWebHelper.cs b/Duplicati/Library/Backend/OAuthHelper/JSONWebHelper.cs index dbe43c18c..ef5e13a3e 100644 --- a/Duplicati/Library/Backend/OAuthHelper/JSONWebHelper.cs +++ b/Duplicati/Library/Backend/OAuthHelper/JSONWebHelper.cs @@ -134,9 +134,10 @@ namespace Duplicati.Library CreateBoundary(out var boundary, out var bodyTerminator); var req = PreparePostMultipart(url, setup, boundary, bodyTerminator, out var headers, parts); + var areq = new AsyncHttpRequest(req); var buffer = new byte[Utility.Utility.DEFAULT_BUFFER_SIZE]; - using (var rs = await req.GetRequestStreamAsync().ConfigureAwait(false)) + using (var rs = areq.GetRequestStream()) { foreach (var p in headers) { diff --git a/Duplicati/Library/Main/Database/LocalRecreateDatabase.cs b/Duplicati/Library/Main/Database/LocalRecreateDatabase.cs index fd64b47cc..769025026 100644 --- a/Duplicati/Library/Main/Database/LocalRecreateDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalRecreateDatabase.cs @@ -498,8 +498,8 @@ namespace Duplicati.Library.Main.Database blocksize / hashsize ); - var missingBlockInfo = - @"SELECT ""VolumeID"" FROM ""Block"" WHERE ""VolumeID"" < 0 "; + var missingBlockInfo = + @"SELECT ""VolumeID"" FROM ""Block"" WHERE ""VolumeID"" < 0 AND SIZE > 0"; var missingBlocklistVolumes = string.Format( @"SELECT ""VolumeID"" FROM ""Block"", (" + diff --git a/Duplicati/Library/Modules/Builtin/ReportHelper.cs b/Duplicati/Library/Modules/Builtin/ReportHelper.cs index f6bdc1274..ca83f31bc 100644 --- a/Duplicati/Library/Modules/Builtin/ReportHelper.cs +++ b/Duplicati/Library/Modules/Builtin/ReportHelper.cs @@ -292,7 +292,7 @@ namespace Duplicati.Library.Modules.Builtin protected virtual string ReplaceTemplate(string input, object result, bool subjectline) { // For JSON, ignore the template and just use the contents - if (ExportFormat == ResultExportFormat.Json) + if (ExportFormat == ResultExportFormat.Json && !subjectline) { var extra = new Dictionary();