From 65866f13d386e4f9441901c20fd098d76c5ccb58 Mon Sep 17 00:00:00 2001 From: wjan Date: Tue, 9 Jan 2018 09:41:40 +0100 Subject: Corrects the folder of Rclone contributions --- .../Rclone/Duplicati.Library.Backend.Rclone.csproj | 65 +++++ .../Duplicati.Library.Backend.Rclone.csproj | 65 ----- .../Properties/AssemblyInfo.cs | 43 ---- .../Duplicati.Library.Backend.Rclone/Rclone.cs | 273 --------------------- .../Duplicati.Library.Backend.Rclone/Strings.cs | 18 -- .../packages.config | 4 - .../Backend/Rclone/Properties/AssemblyInfo.cs | 43 ++++ Duplicati/Library/Backend/Rclone/Rclone.cs | 273 +++++++++++++++++++++ Duplicati/Library/Backend/Rclone/Strings.cs | 18 ++ Duplicati/Library/Backend/Rclone/packages.config | 4 + 10 files changed, 403 insertions(+), 403 deletions(-) create mode 100644 Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone.csproj delete mode 100644 Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Duplicati.Library.Backend.Rclone.csproj delete mode 100644 Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Properties/AssemblyInfo.cs delete mode 100644 Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Rclone.cs delete mode 100644 Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Strings.cs delete mode 100644 Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/packages.config create mode 100644 Duplicati/Library/Backend/Rclone/Properties/AssemblyInfo.cs create mode 100644 Duplicati/Library/Backend/Rclone/Rclone.cs create mode 100644 Duplicati/Library/Backend/Rclone/Strings.cs create mode 100644 Duplicati/Library/Backend/Rclone/packages.config (limited to 'Duplicati/Library/Backend') diff --git a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone.csproj b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone.csproj new file mode 100644 index 000000000..884ba233a --- /dev/null +++ b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone.csproj @@ -0,0 +1,65 @@ + + + + Debug + AnyCPU + {851A1CB8-3CEB-41B4-956F-34D760D2A8E5} + Library + Duplicati.Library.Backend.Rclone + Duplicati.Library.Backend.Rclone + Duplicati.snk + v4.5 + false + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + full + true + bin\Release + prompt + 4 + false + + + + ..\..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + {DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65} + Duplicati.Library.Utility + + + {D4C37C33-5E73-4B56-B2C3-DC4A6BAA36BB} + Duplicati.Library.OAuthHelper + + + {B68F2214-951F-4F78-8488-66E1ED3F50BF} + Duplicati.Library.Localization + + + {C5899F45-B0FF-483C-9D38-24A9FCAAB237} + Duplicati.Library.Interface + + + + + + \ No newline at end of file diff --git a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Duplicati.Library.Backend.Rclone.csproj b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Duplicati.Library.Backend.Rclone.csproj deleted file mode 100644 index 884ba233a..000000000 --- a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Duplicati.Library.Backend.Rclone.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - Debug - AnyCPU - {851A1CB8-3CEB-41B4-956F-34D760D2A8E5} - Library - Duplicati.Library.Backend.Rclone - Duplicati.Library.Backend.Rclone - Duplicati.snk - v4.5 - false - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - false - - - full - true - bin\Release - prompt - 4 - false - - - - ..\..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - {DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65} - Duplicati.Library.Utility - - - {D4C37C33-5E73-4B56-B2C3-DC4A6BAA36BB} - Duplicati.Library.OAuthHelper - - - {B68F2214-951F-4F78-8488-66E1ED3F50BF} - Duplicati.Library.Localization - - - {C5899F45-B0FF-483C-9D38-24A9FCAAB237} - Duplicati.Library.Interface - - - - - - \ No newline at end of file diff --git a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Properties/AssemblyInfo.cs b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Properties/AssemblyInfo.cs deleted file mode 100644 index e5f61e911..000000000 --- a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -// 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 -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Duplicati.Library.Backend.Rclone")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("2.0.0.7")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Rclone.cs b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Rclone.cs deleted file mode 100644 index d07ad7672..000000000 --- a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Rclone.cs +++ /dev/null @@ -1,273 +0,0 @@ -#region Disclaimer / License -// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -// -#endregion -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; -using Duplicati.Library.Interface; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Duplicati.Library.Backend -{ - public class Rclone : IBackend - { - private const string OPTION_LOCAL_REPO = "rclone-local-repository"; - private const string OPTION_REMOTE_REPO = "rclone-remote-repository"; - private const string OPTION_REMOTE_PATH = "rclone-remote-path"; - private const string OPTION_RCLONE = "rclone-option"; - - private string local_repo; - private string remote_repo; - private string remote_path; - private string opt_rclone; - - public Rclone() - { - - } - - public Rclone(string url, Dictionary options) - { - - local_repo = "local"; - remote_repo = "remote"; - remote_path = "backup"; - opt_rclone = ""; - /*should check here if program is installed */ - - if (options.ContainsKey(OPTION_LOCAL_REPO)) - local_repo = options[OPTION_LOCAL_REPO]; - - if (options.ContainsKey(OPTION_REMOTE_REPO)) - remote_repo = options[OPTION_REMOTE_REPO]; - - if (options.ContainsKey(OPTION_REMOTE_PATH)) - remote_path = options[OPTION_REMOTE_PATH]; - - if (options.ContainsKey(OPTION_RCLONE)) - opt_rclone = options[OPTION_RCLONE]; - - - Console.Error.WriteLine(string.Format("Constructor {0}: {1}:{2} {3}", local_repo, remote_repo, remote_path, opt_rclone)); - - } - - #region IBackendInterface Members - - public string DisplayName - { - get { return Strings.Rclone.DisplayName; } - } - - public string ProtocolKey - { - get { return "rclone"; } - } - - public bool SupportsStreaming - { - get { return false; } - } - - public IEnumerable List() - { - //Console.Error.WriteLine(string.Format("Listing contents: rclone lsjson {0}:{1}",remote_repo, remote_path)); - - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); - psi.Arguments = String.Format("lsjson {0}/{1}", remote_repo, remote_path); - psi.CreateNoWindow = true; - psi.FileName = "rclone"; - psi.RedirectStandardError = true; - psi.RedirectStandardInput = true; - psi.RedirectStandardOutput = true; - psi.UseShellExecute = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - -#if DEBUG - psi.CreateNoWindow = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; -#endif - System.Diagnostics.Process p = null; - Console.Error.WriteLine("before try"); - try - { - Console.Error.WriteLine("process listing starting: {0} {1}", psi.FileName, psi.Arguments); - p = System.Diagnostics.Process.Start(psi); - // this will give an error if eg. the program does not exist - Console.Error.WriteLine("process listing started"); - } - - catch (System.ComponentModel.Win32Exception ex) - { - Console.Error.WriteLine("Inside catch"); - throw new Exception("Program does not exist", ex); - } - - String result = p.StandardOutput.ReadToEnd(); - JArray files = JArray.Parse(result); - // this will give an error if the path or config does not exist. - - //if (!System.IO.Directory.Exists(m_path)) - // throw new FolderMissingException(Strings.FileBackend.FolderMissingError(m_path)); - foreach (JObject item in files) - { - FileEntry fe = new FileEntry( - item.GetValue("Name").Value(), - item.GetValue("Size").Value(), - DateTime.Parse(item.GetValue("ModTime").Value()), - DateTime.Parse(item.GetValue("ModTime").Value()) - ); - fe.IsFolder = item.GetValue("IsDir").Value(); - yield return fe; - - - } - } - - public void Put(string remotename, string filename) - { - - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); - psi.Arguments = String.Format("copyto {0}:{1} {2}:{3}/{4}", local_repo, filename, remote_repo, remote_path, remotename); - psi.CreateNoWindow = true; - psi.FileName = "rclone"; - psi.RedirectStandardError = true; - psi.RedirectStandardInput = true; - psi.RedirectStandardOutput = true; - psi.UseShellExecute = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - -#if DEBUG - psi.CreateNoWindow = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; -#endif - - System.Diagnostics.Process p; - p = System.Diagnostics.Process.Start(psi); - - String result_out = p.StandardOutput.ReadToEnd(); - String result_err = p.StandardError.ReadToEnd(); - Console.Error.WriteLine(result_out); - Console.Error.WriteLine(result_err); - } - - public void Get(string remotename, string filename) - { - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); - psi.Arguments = String.Format("copyto {2}:{3}/{4} {0}:{1}", local_repo, filename, remote_repo, remote_path, remotename); - psi.CreateNoWindow = true; - psi.FileName = "rclone"; - psi.RedirectStandardError = true; - psi.RedirectStandardInput = true; - psi.RedirectStandardOutput = true; - psi.UseShellExecute = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - -#if DEBUG - psi.CreateNoWindow = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; -#endif - - System.Diagnostics.Process p; - p = System.Diagnostics.Process.Start(psi); - - String result_out = p.StandardOutput.ReadToEnd(); - String result_err = p.StandardError.ReadToEnd(); - Console.Error.WriteLine(result_out); - Console.Error.WriteLine(result_err); - } - - public void Delete(string remotename) - { - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); - psi.Arguments = String.Format("delete {0}:{1}/{2}", remote_repo, remote_path, remotename); - psi.CreateNoWindow = true; - psi.FileName = "rclone"; - psi.RedirectStandardError = true; - psi.RedirectStandardInput = true; - psi.RedirectStandardOutput = true; - psi.UseShellExecute = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - -#if DEBUG - psi.CreateNoWindow = false; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; -#endif - - System.Diagnostics.Process p; - p = System.Diagnostics.Process.Start(psi); - - String result_out = p.StandardOutput.ReadToEnd(); - String result_err = p.StandardError.ReadToEnd(); - Console.Error.WriteLine(result_out); - Console.Error.WriteLine(result_err); - } - - public IList SupportedCommands - { - get - { - return new List(new ICommandLineArgument[] { - new CommandLineArgument(OPTION_LOCAL_REPO, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneLocalRepoShort, Strings.Rclone.RcloneLocalRepoLong, "local"), - new CommandLineArgument(OPTION_REMOTE_REPO, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneRemoteRepoShort, Strings.Rclone.RcloneRemoteRepoLong, "remote"), - new CommandLineArgument(OPTION_REMOTE_PATH, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneRemotePathShort, Strings.Rclone.RcloneRemotePathLong, "backup"), - new CommandLineArgument(OPTION_RCLONE, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneOptionRcloneShort, Strings.Rclone.RcloneOptionRcloneLong, ""), - }); - - } - } - - public string Description - { - get - { - return Strings.Rclone.Description; - } - } - - public void Test() - { - this.TestList(); - } - - public void CreateFolder() - { - /* if (System.IO.Directory.Exists(m_path)) - throw new FolderAreadyExistedException(); - - System.IO.Directory.CreateDirectory(m_path);*/ - } - - #endregion - - #region IDisposable Members - - public void Dispose() - { - - } - - #endregion - - - - } -} diff --git a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Strings.cs b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Strings.cs deleted file mode 100644 index a10e29347..000000000 --- a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Strings.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Duplicati.Library.Localization.Short; -namespace Duplicati.Library.Backend.Strings -{ - internal static class Rclone - { - public static string DisplayName { get { return LC.L(@"Rclone"); } } - public static string Description { get { return LC.L(@"This backend can read and write data to Rclone."); } } - public static string RcloneLocalRepoShort { get { return LC.L(@"Local repository"); } } - public static string RcloneLocalRepoLong { get { return LC.L(@"Local repository"); } } - public static string RcloneRemoteRepoShort { get { return LC.L(@"Remote repository"); } } - public static string RcloneRemoteRepoLong { get { return LC.L(@"Remote repository"); } } - public static string RcloneRemotePathShort { get { return LC.L(@"Remote path"); } } - public static string RcloneRemotePathLong { get { return LC.L(@"Remote path"); } } - public static string RcloneOptionRcloneShort { get { return LC.L(@"Rclone options"); } } - public static string RcloneOptionRcloneLong { get { return LC.L(@"Rclone options"); } } - - } -} diff --git a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/packages.config b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/packages.config deleted file mode 100644 index ee51c2373..000000000 --- a/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Duplicati/Library/Backend/Rclone/Properties/AssemblyInfo.cs b/Duplicati/Library/Backend/Rclone/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..e5f61e911 --- /dev/null +++ b/Duplicati/Library/Backend/Rclone/Properties/AssemblyInfo.cs @@ -0,0 +1,43 @@ +// 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 +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("Duplicati.Library.Backend.Rclone")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("2.0.0.7")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Duplicati/Library/Backend/Rclone/Rclone.cs b/Duplicati/Library/Backend/Rclone/Rclone.cs new file mode 100644 index 000000000..d07ad7672 --- /dev/null +++ b/Duplicati/Library/Backend/Rclone/Rclone.cs @@ -0,0 +1,273 @@ +#region Disclaimer / License +// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +#endregion +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using Duplicati.Library.Interface; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Duplicati.Library.Backend +{ + public class Rclone : IBackend + { + private const string OPTION_LOCAL_REPO = "rclone-local-repository"; + private const string OPTION_REMOTE_REPO = "rclone-remote-repository"; + private const string OPTION_REMOTE_PATH = "rclone-remote-path"; + private const string OPTION_RCLONE = "rclone-option"; + + private string local_repo; + private string remote_repo; + private string remote_path; + private string opt_rclone; + + public Rclone() + { + + } + + public Rclone(string url, Dictionary options) + { + + local_repo = "local"; + remote_repo = "remote"; + remote_path = "backup"; + opt_rclone = ""; + /*should check here if program is installed */ + + if (options.ContainsKey(OPTION_LOCAL_REPO)) + local_repo = options[OPTION_LOCAL_REPO]; + + if (options.ContainsKey(OPTION_REMOTE_REPO)) + remote_repo = options[OPTION_REMOTE_REPO]; + + if (options.ContainsKey(OPTION_REMOTE_PATH)) + remote_path = options[OPTION_REMOTE_PATH]; + + if (options.ContainsKey(OPTION_RCLONE)) + opt_rclone = options[OPTION_RCLONE]; + + + Console.Error.WriteLine(string.Format("Constructor {0}: {1}:{2} {3}", local_repo, remote_repo, remote_path, opt_rclone)); + + } + + #region IBackendInterface Members + + public string DisplayName + { + get { return Strings.Rclone.DisplayName; } + } + + public string ProtocolKey + { + get { return "rclone"; } + } + + public bool SupportsStreaming + { + get { return false; } + } + + public IEnumerable List() + { + //Console.Error.WriteLine(string.Format("Listing contents: rclone lsjson {0}:{1}",remote_repo, remote_path)); + + System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); + psi.Arguments = String.Format("lsjson {0}/{1}", remote_repo, remote_path); + psi.CreateNoWindow = true; + psi.FileName = "rclone"; + psi.RedirectStandardError = true; + psi.RedirectStandardInput = true; + psi.RedirectStandardOutput = true; + psi.UseShellExecute = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + +#if DEBUG + psi.CreateNoWindow = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; +#endif + System.Diagnostics.Process p = null; + Console.Error.WriteLine("before try"); + try + { + Console.Error.WriteLine("process listing starting: {0} {1}", psi.FileName, psi.Arguments); + p = System.Diagnostics.Process.Start(psi); + // this will give an error if eg. the program does not exist + Console.Error.WriteLine("process listing started"); + } + + catch (System.ComponentModel.Win32Exception ex) + { + Console.Error.WriteLine("Inside catch"); + throw new Exception("Program does not exist", ex); + } + + String result = p.StandardOutput.ReadToEnd(); + JArray files = JArray.Parse(result); + // this will give an error if the path or config does not exist. + + //if (!System.IO.Directory.Exists(m_path)) + // throw new FolderMissingException(Strings.FileBackend.FolderMissingError(m_path)); + foreach (JObject item in files) + { + FileEntry fe = new FileEntry( + item.GetValue("Name").Value(), + item.GetValue("Size").Value(), + DateTime.Parse(item.GetValue("ModTime").Value()), + DateTime.Parse(item.GetValue("ModTime").Value()) + ); + fe.IsFolder = item.GetValue("IsDir").Value(); + yield return fe; + + + } + } + + public void Put(string remotename, string filename) + { + + System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); + psi.Arguments = String.Format("copyto {0}:{1} {2}:{3}/{4}", local_repo, filename, remote_repo, remote_path, remotename); + psi.CreateNoWindow = true; + psi.FileName = "rclone"; + psi.RedirectStandardError = true; + psi.RedirectStandardInput = true; + psi.RedirectStandardOutput = true; + psi.UseShellExecute = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + +#if DEBUG + psi.CreateNoWindow = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; +#endif + + System.Diagnostics.Process p; + p = System.Diagnostics.Process.Start(psi); + + String result_out = p.StandardOutput.ReadToEnd(); + String result_err = p.StandardError.ReadToEnd(); + Console.Error.WriteLine(result_out); + Console.Error.WriteLine(result_err); + } + + public void Get(string remotename, string filename) + { + System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); + psi.Arguments = String.Format("copyto {2}:{3}/{4} {0}:{1}", local_repo, filename, remote_repo, remote_path, remotename); + psi.CreateNoWindow = true; + psi.FileName = "rclone"; + psi.RedirectStandardError = true; + psi.RedirectStandardInput = true; + psi.RedirectStandardOutput = true; + psi.UseShellExecute = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + +#if DEBUG + psi.CreateNoWindow = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; +#endif + + System.Diagnostics.Process p; + p = System.Diagnostics.Process.Start(psi); + + String result_out = p.StandardOutput.ReadToEnd(); + String result_err = p.StandardError.ReadToEnd(); + Console.Error.WriteLine(result_out); + Console.Error.WriteLine(result_err); + } + + public void Delete(string remotename) + { + System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); + psi.Arguments = String.Format("delete {0}:{1}/{2}", remote_repo, remote_path, remotename); + psi.CreateNoWindow = true; + psi.FileName = "rclone"; + psi.RedirectStandardError = true; + psi.RedirectStandardInput = true; + psi.RedirectStandardOutput = true; + psi.UseShellExecute = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + +#if DEBUG + psi.CreateNoWindow = false; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; +#endif + + System.Diagnostics.Process p; + p = System.Diagnostics.Process.Start(psi); + + String result_out = p.StandardOutput.ReadToEnd(); + String result_err = p.StandardError.ReadToEnd(); + Console.Error.WriteLine(result_out); + Console.Error.WriteLine(result_err); + } + + public IList SupportedCommands + { + get + { + return new List(new ICommandLineArgument[] { + new CommandLineArgument(OPTION_LOCAL_REPO, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneLocalRepoShort, Strings.Rclone.RcloneLocalRepoLong, "local"), + new CommandLineArgument(OPTION_REMOTE_REPO, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneRemoteRepoShort, Strings.Rclone.RcloneRemoteRepoLong, "remote"), + new CommandLineArgument(OPTION_REMOTE_PATH, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneRemotePathShort, Strings.Rclone.RcloneRemotePathLong, "backup"), + new CommandLineArgument(OPTION_RCLONE, CommandLineArgument.ArgumentType.String, Strings.Rclone.RcloneOptionRcloneShort, Strings.Rclone.RcloneOptionRcloneLong, ""), + }); + + } + } + + public string Description + { + get + { + return Strings.Rclone.Description; + } + } + + public void Test() + { + this.TestList(); + } + + public void CreateFolder() + { + /* if (System.IO.Directory.Exists(m_path)) + throw new FolderAreadyExistedException(); + + System.IO.Directory.CreateDirectory(m_path);*/ + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + + } + + #endregion + + + + } +} diff --git a/Duplicati/Library/Backend/Rclone/Strings.cs b/Duplicati/Library/Backend/Rclone/Strings.cs new file mode 100644 index 000000000..a10e29347 --- /dev/null +++ b/Duplicati/Library/Backend/Rclone/Strings.cs @@ -0,0 +1,18 @@ +using Duplicati.Library.Localization.Short; +namespace Duplicati.Library.Backend.Strings +{ + internal static class Rclone + { + public static string DisplayName { get { return LC.L(@"Rclone"); } } + public static string Description { get { return LC.L(@"This backend can read and write data to Rclone."); } } + public static string RcloneLocalRepoShort { get { return LC.L(@"Local repository"); } } + public static string RcloneLocalRepoLong { get { return LC.L(@"Local repository"); } } + public static string RcloneRemoteRepoShort { get { return LC.L(@"Remote repository"); } } + public static string RcloneRemoteRepoLong { get { return LC.L(@"Remote repository"); } } + public static string RcloneRemotePathShort { get { return LC.L(@"Remote path"); } } + public static string RcloneRemotePathLong { get { return LC.L(@"Remote path"); } } + public static string RcloneOptionRcloneShort { get { return LC.L(@"Rclone options"); } } + public static string RcloneOptionRcloneLong { get { return LC.L(@"Rclone options"); } } + + } +} diff --git a/Duplicati/Library/Backend/Rclone/packages.config b/Duplicati/Library/Backend/Rclone/packages.config new file mode 100644 index 000000000..ee51c2373 --- /dev/null +++ b/Duplicati/Library/Backend/Rclone/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.2.3