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:
authorwjan <wim.jansen@gmail.com>2018-01-09 11:12:06 +0300
committerwjan <wim.jansen@gmail.com>2018-01-09 11:12:06 +0300
commit63061d533c3965454efba01f59e7a86641ba14fd (patch)
tree30298e50f0a798d73ec9df1e3288a6462f6b9148 /Duplicati/Library/Backend
parenta04862d9f524d548d74d95e4618ea57a15dc853d (diff)
provides rclone backend
Diffstat (limited to 'Duplicati/Library/Backend')
-rw-r--r--Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Duplicati.Library.Backend.Rclone.csproj65
-rw-r--r--Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Properties/AssemblyInfo.cs43
-rw-r--r--Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Rclone.cs273
-rw-r--r--Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Strings.cs18
-rw-r--r--Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/packages.config4
5 files changed, 403 insertions, 0 deletions
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
new file mode 100644
index 000000000..884ba233a
--- /dev/null
+++ b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Duplicati.Library.Backend.Rclone.csproj
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{851A1CB8-3CEB-41B4-956F-34D760D2A8E5}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Duplicati.Library.Backend.Rclone</RootNamespace>
+ <AssemblyName>Duplicati.Library.Backend.Rclone</AssemblyName>
+ <AssemblyOriginatorKeyFile>Duplicati.snk</AssemblyOriginatorKeyFile>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <UseMSBuildEngine>false</UseMSBuildEngine>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Rclone.cs" />
+ <Compile Include="Strings.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\Utility\Duplicati.Library.Utility.csproj">
+ <Project>{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}</Project>
+ <Name>Duplicati.Library.Utility</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\OAuthHelper\Duplicati.Library.OAuthHelper.csproj">
+ <Project>{D4C37C33-5E73-4B56-B2C3-DC4A6BAA36BB}</Project>
+ <Name>Duplicati.Library.OAuthHelper</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\Localization\Duplicati.Library.Localization.csproj">
+ <Project>{B68F2214-951F-4F78-8488-66E1ED3F50BF}</Project>
+ <Name>Duplicati.Library.Localization</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\Interface\Duplicati.Library.Interface.csproj">
+ <Project>{C5899F45-B0FF-483C-9D38-24A9FCAAB237}</Project>
+ <Name>Duplicati.Library.Interface</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+</Project> \ 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
new file mode 100644
index 000000000..e5f61e911
--- /dev/null
+++ b/Duplicati/Library/Backend/Rclone/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/Duplicati.Library.Backend.Rclone/Rclone.cs b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/Rclone.cs
new file mode 100644
index 000000000..d07ad7672
--- /dev/null
+++ b/Duplicati/Library/Backend/Rclone/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<string, string> 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<IFileEntry> 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<string>(),
+ item.GetValue("Size").Value<long>(),
+ DateTime.Parse(item.GetValue("ModTime").Value<string>()),
+ DateTime.Parse(item.GetValue("ModTime").Value<string>())
+ );
+ fe.IsFolder = item.GetValue("IsDir").Value<bool>();
+ 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<ICommandLineArgument> SupportedCommands
+ {
+ get
+ {
+ return new List<ICommandLineArgument>(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
new file mode 100644
index 000000000..a10e29347
--- /dev/null
+++ b/Duplicati/Library/Backend/Rclone/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/Duplicati.Library.Backend.Rclone/packages.config b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/packages.config
new file mode 100644
index 000000000..ee51c2373
--- /dev/null
+++ b/Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
+</packages> \ No newline at end of file