From ee9be320d0eb3a1e75620bef1ca38e257a0cc68c Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 23 Jul 2013 20:53:34 +0200 Subject: [PATCH] Added compile flag to activate random transmission errors --- Duplicati/Library/Backend/File/FileBackend.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Duplicati/Library/Backend/File/FileBackend.cs b/Duplicati/Library/Backend/File/FileBackend.cs index ad30c2ae7..849003eb3 100644 --- a/Duplicati/Library/Backend/File/FileBackend.cs +++ b/Duplicati/Library/Backend/File/FileBackend.cs @@ -184,11 +184,24 @@ namespace Duplicati.Library.Backend return ls; } +#if DEBUG_RETRY + private static Random random = new Random(); public void Put(string remotename, System.IO.Stream stream) { - using (System.IO.FileStream writestream = System.IO.File.Open(GetRemoteName(remotename), System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) + using(System.IO.FileStream writestream = System.IO.File.Open(GetRemoteName(remotename), System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) + { + if (random.NextDouble() > 0.6666) + throw new Exception("Random upload failure"); + Utility.Utility.CopyStream(stream, writestream); + } + } +#else + public void Put(string remotename, System.IO.Stream stream) + { + using(System.IO.FileStream writestream = System.IO.File.Open(GetRemoteName(remotename), System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) Utility.Utility.CopyStream(stream, writestream); } +#endif public void Get(string remotename, System.IO.Stream stream) {