upstream
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Log output handler for the console
|
||||
/// </summary>
|
||||
public class ConsoleLogTarget : Library.Logging.ILogDestination
|
||||
{
|
||||
/// <summary>
|
||||
/// The stdout stream
|
||||
/// </summary>
|
||||
private readonly TextWriter m_stdout;
|
||||
/// <summary>
|
||||
/// The stderr stream
|
||||
/// </summary>
|
||||
private readonly TextWriter m_stderr;
|
||||
/// <summary>
|
||||
/// The default log level
|
||||
/// </summary>
|
||||
private readonly LogMessageType m_level;
|
||||
/// <summary>
|
||||
/// The filter, if any
|
||||
/// </summary>
|
||||
private readonly IFilter m_filter;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:Duplicati.CommandLine.ConsoleLogTarget"/> class.
|
||||
/// </summary>
|
||||
/// <param name="stdout">The stdout stream.</param>
|
||||
/// <param name="stderr">The stderr stream.</param>
|
||||
/// <param name="level">The minimum log level to consider.</param>
|
||||
/// <param name="logfilter">The log filter, if any.</param>
|
||||
public ConsoleLogTarget(TextWriter stdout, TextWriter stderr, LogMessageType level, string logfilter)
|
||||
{
|
||||
m_stdout = stdout;
|
||||
m_stderr = stderr;
|
||||
m_level = level;
|
||||
m_filter = FilterExpression.ParseLogFilter(logfilter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the message to stdout or stderr.
|
||||
/// </summary>
|
||||
/// <param name="entry">The entry to write.</param>
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<IMenuItem> items)
|
||||
|
||||
@@ -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<string, string> Query;
|
||||
|
||||
public BackgroundRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public BackgroundRequest(string method, string endpoint, Dictionary<string, string> query)
|
||||
{
|
||||
this.Method = method;
|
||||
|
||||
@@ -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<string>();
|
||||
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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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"", (" +
|
||||
|
||||
@@ -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<string, string>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user