Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlueBlock <danb@pobox.com>2019-07-18 19:15:01 +0300
committerBlueBlock <danb@pobox.com>2019-07-20 22:04:07 +0300
commit4884fda0c69828cb5f1b4ff8e560323a45a58bf5 (patch)
tree89e20bd3ec0556337849991555ef1a2229b3d115 /Duplicati/CommandLine
parent55a55cf18e8b8b32cb847c44383f0c1e5ec06cca (diff)
Add ability for gpg encryption to use the Windows gpg4win installed gpg.exe if it exists
Diffstat (limited to 'Duplicati/CommandLine')
-rw-r--r--Duplicati/CommandLine/Program.cs57
1 files changed, 37 insertions, 20 deletions
diff --git a/Duplicati/CommandLine/Program.cs b/Duplicati/CommandLine/Program.cs
index 5eef3343e..0d46ffd3d 100644
--- a/Duplicati/CommandLine/Program.cs
+++ b/Duplicati/CommandLine/Program.cs
@@ -22,8 +22,8 @@ using System.Collections.Generic;
using System.Linq;
using Duplicati.Library.Localization.Short;
using System.IO;
-using Duplicati.Library.Common;
-
+using Duplicati.Library.Common;
+
namespace Duplicati.CommandLine
{
public class Program
@@ -48,16 +48,29 @@ namespace Duplicati.CommandLine
FROM_COMMANDLINE = true;
try
{
- //If we are on Windows, append the bundled "win-tools" programs to the search path
+ //If we are on Windows, append the gpg4win path and append the bundled "win-tools" programs to the search path
//We add it last, to allow the user to override with other versions
if (Platform.IsClientWindows)
{
+ var ExternalGpgPath = @"C:\Program Files (x86)\GnuPG\bin";
+ var gpg4win = System.IO.Path.Combine(ExternalGpgPath, "gpg.exe");
+
+ if (File.Exists(gpg4win))
+ {
+ Environment.SetEnvironmentVariable("PATH",
+ Environment.GetEnvironmentVariable("PATH") +
+ System.IO.Path.PathSeparator +
+ gpg4win
+ );
+ }
+
string wintools = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "win-tools");
+
Environment.SetEnvironmentVariable("PATH",
Environment.GetEnvironmentVariable("PATH") +
- System.IO.Path.PathSeparator.ToString() +
+ System.IO.Path.PathSeparator +
wintools +
- System.IO.Path.PathSeparator.ToString() +
+ System.IO.Path.PathSeparator +
System.IO.Path.Combine(wintools, "gpg") //GPG needs to be in a subfolder for wrapping reasons
);
}
@@ -112,13 +125,15 @@ namespace Duplicati.CommandLine
public static IEnumerable<string> SupportedCommands { get { return CommandMap.Keys; } }
- private static int ShowChangeLog(TextWriter outwriter) {
+ private static int ShowChangeLog(TextWriter outwriter)
+ {
var path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "changelog.txt");
outwriter.WriteLine(System.IO.File.ReadAllText(path));
return 0;
}
- private static void CheckForUpdates(TextWriter outwriter){
+ private static void CheckForUpdates(TextWriter outwriter)
+ {
var update = Library.AutoUpdater.UpdaterManager.LastUpdateCheckVersion;
if (update == null)
update = Library.AutoUpdater.UpdaterManager.CheckForUpdate();
@@ -140,7 +155,8 @@ namespace Duplicati.CommandLine
}
}
- private static int ParseCommandLine(TextWriter outwriter, Action<Library.Main.Controller> setup, ref bool verboseErrors, string[] args) {
+ private static int ParseCommandLine(TextWriter outwriter, Action<Library.Main.Controller> setup, ref bool verboseErrors, string[] args)
+ {
List<string> cargs = new List<string>(args);
var tmpparsed = Library.Utility.FilterCollector.ExtractOptions(cargs);
@@ -168,7 +184,7 @@ namespace Duplicati.CommandLine
}
// try and parse all parameter file aliases
- foreach (string parameterOption in new []{ "parameters-file", "parameters-file", "parameterfile"} )
+ foreach (string parameterOption in new[] { "parameters-file", "parameters-file", "parameterfile" })
{
if (options.ContainsKey(parameterOption) && !string.IsNullOrEmpty(options[parameterOption]))
{
@@ -305,7 +321,8 @@ namespace Duplicati.CommandLine
string appendfilter = null;
string replacefilter = null;
- var tmpparsed = Library.Utility.FilterCollector.ExtractOptions(fargs, (key, value) => {
+ var tmpparsed = Library.Utility.FilterCollector.ExtractOptions(fargs, (key, value) =>
+ {
if (key.Equals("source", StringComparison.OrdinalIgnoreCase))
{
newsource.Add(value);
@@ -347,27 +364,27 @@ namespace Duplicati.CommandLine
filter = newfilter;
if (!string.IsNullOrWhiteSpace(prependfilter))
- filter = Library.Utility.FilterExpression.Combine(Library.Utility.FilterExpression.Deserialize(prependfilter.Split(new string[] {System.IO.Path.PathSeparator.ToString()}, StringSplitOptions.RemoveEmptyEntries)), filter);
+ filter = Library.Utility.FilterExpression.Combine(Library.Utility.FilterExpression.Deserialize(prependfilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries)), filter);
if (!string.IsNullOrWhiteSpace(appendfilter))
- filter = Library.Utility.FilterExpression.Combine(filter, Library.Utility.FilterExpression.Deserialize(appendfilter.Split(new string[] {System.IO.Path.PathSeparator.ToString()}, StringSplitOptions.RemoveEmptyEntries)));
+ filter = Library.Utility.FilterExpression.Combine(filter, Library.Utility.FilterExpression.Deserialize(appendfilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries)));
if (!string.IsNullOrWhiteSpace(replacefilter))
- filter = Library.Utility.FilterExpression.Deserialize(replacefilter.Split(new string[] {System.IO.Path.PathSeparator.ToString()}, StringSplitOptions.RemoveEmptyEntries));
+ filter = Library.Utility.FilterExpression.Deserialize(replacefilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries));
foreach (KeyValuePair<String, String> keyvalue in opt)
options[keyvalue.Key] = keyvalue.Value;
if (!string.IsNullOrEmpty(newtarget))
- {
- if (cargs.Count <= 1)
- cargs.Add(newtarget);
- else
- cargs[1] = newtarget;
- }
+ {
+ if (cargs.Count <= 1)
+ cargs.Add(newtarget);
+ else
+ cargs[1] = newtarget;
+ }
if (cargs.Count >= 1 && cargs[0].Equals("backup", StringComparison.OrdinalIgnoreCase))
- cargs.AddRange(newsource);
+ cargs.AddRange(newsource);
else if (newsource.Count > 0)
Library.Logging.Log.WriteVerboseMessage(LOGTAG, "NotUsingBackupSources", Strings.Program.SkippingSourceArgumentsOnNonBackupOperation);