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:
authorSean Templeton <seantempleton@outlook.com>2019-02-23 18:19:20 +0300
committerSean Templeton <seantempleton@outlook.com>2019-03-06 06:25:29 +0300
commit13f83a22a110090de76b37b955e6cd7f89ca40fc (patch)
tree14cf69b2d2d64b1e2083b2cacb04f1c7a7190c7b /Duplicati/Library/Backend/Rclone
parentc3472823de5b0a2856c609a1317e46b1dc360972 (diff)
Update Mega, OneDrive, and Rclone backends for async Put
Diffstat (limited to 'Duplicati/Library/Backend/Rclone')
-rw-r--r--Duplicati/Library/Backend/Rclone/Rclone.cs27
1 files changed, 18 insertions, 9 deletions
diff --git a/Duplicati/Library/Backend/Rclone/Rclone.cs b/Duplicati/Library/Backend/Rclone/Rclone.cs
index be5b0b0b7..df128554b 100644
--- a/Duplicati/Library/Backend/Rclone/Rclone.cs
+++ b/Duplicati/Library/Backend/Rclone/Rclone.cs
@@ -19,6 +19,7 @@
#endregion
using Duplicati.Library.Common.IO;
using Duplicati.Library.Interface;
+using Duplicati.Library.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@@ -97,7 +98,7 @@ namespace Duplicati.Library.Backend
get { return false; }
}
- private string RcloneCommandExecuter(String command, String arguments)
+ private async Task<string> RcloneCommandExecuter(String command, String arguments, CancellationToken cancelToken)
{
StringBuilder outputBuilder = new StringBuilder();
StringBuilder errorBuilder = new StringBuilder();
@@ -162,7 +163,17 @@ namespace Duplicati.Library.Backend
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
- process.WaitForExit();
+
+ while(!process.HasExited)
+ {
+ await Task.Delay(500).ConfigureAwait(false);
+ if (cancelToken.IsCancellationRequested)
+ {
+ process.Kill();
+ process.WaitForExit();
+ }
+ }
+
process.CancelOutputRead();
process.CancelErrorRead();
@@ -191,7 +202,7 @@ namespace Duplicati.Library.Backend
try
{
- str_result = RcloneCommandExecuter(rclone_executable, String.Format("lsjson {0}:{1}", remote_repo, remote_path));
+ str_result = RcloneCommandExecuter(rclone_executable, String.Format("lsjson {0}:{1}", remote_repo, remote_path), CancellationToken.None).Await();
// this will give an error if the executable does not exist.
}
@@ -229,21 +240,19 @@ namespace Duplicati.Library.Backend
{
try
{
- RcloneCommandExecuter(rclone_executable, String.Format("copyto {0}:{1} {2}:{3}/{4}", local_repo, filename, remote_repo, remote_path, remotename));
+ return RcloneCommandExecuter(rclone_executable, String.Format("copyto {0}:{1} {2}:{3}/{4}", local_repo, filename, remote_repo, remote_path, remotename), cancelToken);
}
catch (FolderMissingException ex)
{
throw new FileMissingException(ex);
}
-
- return Task.FromResult(true);
}
public void Get(string remotename, string filename)
{
try
{
- RcloneCommandExecuter(rclone_executable, String.Format("copyto {2}:{3}/{4} {0}:{1}", local_repo, filename, remote_repo, remote_path, remotename));
+ RcloneCommandExecuter(rclone_executable, String.Format("copyto {2}:{3}/{4} {0}:{1}", local_repo, filename, remote_repo, remote_path, remotename), CancellationToken.None).Await();
}
catch (FolderMissingException ex) {
throw new FileMissingException(ex);
@@ -256,7 +265,7 @@ namespace Duplicati.Library.Backend
// Will give a "directory not found" error if the file does not exist, need to change that to a missing file exception
try
{
- RcloneCommandExecuter(rclone_executable, String.Format("delete {0}:{1}/{2}", remote_repo, remote_path, remotename));
+ RcloneCommandExecuter(rclone_executable, String.Format("delete {0}:{1}/{2}", remote_repo, remote_path, remotename), CancellationToken.None).Await();
}
catch (FolderMissingException ex) {
throw new FileMissingException(ex);
@@ -302,7 +311,7 @@ namespace Duplicati.Library.Backend
public void CreateFolder()
{
- RcloneCommandExecuter(rclone_executable, String.Format("mkdir {0}:{1}", remote_repo, remote_path));
+ RcloneCommandExecuter(rclone_executable, String.Format("mkdir {0}:{1}", remote_repo, remote_path), CancellationToken.None).Await();
}
#endregion