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:
authorKenneth Hsu <kennethhsu@gmail.com>2020-11-22 00:58:16 +0300
committerKenneth Hsu <kennethhsu@gmail.com>2020-11-22 00:58:16 +0300
commit5951047ff1a3fc68617763c685ba1bea2f0518b3 (patch)
treecdb03fc7cc4a1a855f1572f41f9d82e53e873be1 /Duplicati/Server
parent7d1d2563150bd2ff47e93a28a985bd9b8736444c (diff)
Fix incorrect or misleading indentations.
This also adds braces to clarify scope where beneficial.
Diffstat (limited to 'Duplicati/Server')
-rw-r--r--Duplicati/Server/Database/Connection.cs38
-rw-r--r--Duplicati/Server/Runner.cs8
-rw-r--r--Duplicati/Server/SingleInstance.cs8
-rw-r--r--Duplicati/Server/WebServer/RESTHandler.cs142
4 files changed, 104 insertions, 92 deletions
diff --git a/Duplicati/Server/Database/Connection.cs b/Duplicati/Server/Database/Connection.cs
index 7f7bcb212..ce9ed53da 100644
--- a/Duplicati/Server/Database/Connection.cs
+++ b/Duplicati/Server/Database/Connection.cs
@@ -476,21 +476,25 @@ namespace Duplicati.Server.Database
internal void UpdateBackupDBPath(IBackup item, string path)
{
- lock(m_lock)
- using(var tr = m_connection.BeginTransaction())
- using(var cmd = m_connection.CreateCommand())
+ lock (m_lock)
{
- cmd.Transaction = tr;
- cmd.Parameters.Add(cmd.CreateParameter());
- ((System.Data.IDbDataParameter)cmd.Parameters[0]).Value = path;
- cmd.Parameters.Add(cmd.CreateParameter());
- ((System.Data.IDbDataParameter)cmd.Parameters[1]).Value = item.ID;
+ using (var tr = m_connection.BeginTransaction())
+ {
+ using (var cmd = m_connection.CreateCommand())
+ {
+ cmd.Transaction = tr;
+ cmd.Parameters.Add(cmd.CreateParameter());
+ ((System.Data.IDbDataParameter) cmd.Parameters[0]).Value = path;
+ cmd.Parameters.Add(cmd.CreateParameter());
+ ((System.Data.IDbDataParameter) cmd.Parameters[1]).Value = item.ID;
- cmd.CommandText = @"UPDATE ""Backup"" SET ""DBPath""=? WHERE ""ID""=?";
- cmd.ExecuteNonQuery();
- tr.Commit();
+ cmd.CommandText = @"UPDATE ""Backup"" SET ""DBPath""=? WHERE ""ID""=?";
+ cmd.ExecuteNonQuery();
+ tr.Commit();
+ }
+ }
}
-
+
System.Threading.Interlocked.Increment(ref Program.LastDataUpdateID);
Program.StatusEventNotifyer.SignalNewEvent();
}
@@ -1104,15 +1108,15 @@ namespace Duplicati.Server.Database
var prop = properties[i];
if (prop.PropertyType.IsEnum)
- prop.SetValue(item, ConvertToEnum(prop.PropertyType, rd, i, Enum.GetValues(prop.PropertyType).GetValue(0)), null);
+ prop.SetValue(item, ConvertToEnum(prop.PropertyType, rd, i, Enum.GetValues(prop.PropertyType).GetValue(0)), null);
else if (prop.PropertyType == typeof(string))
- prop.SetValue(item, ConvertToString(rd, i), null);
+ prop.SetValue(item, ConvertToString(rd, i), null);
else if (prop.PropertyType == typeof(long))
- prop.SetValue(item, ConvertToInt64(rd, i), null);
+ prop.SetValue(item, ConvertToInt64(rd, i), null);
else if (prop.PropertyType == typeof(bool))
- prop.SetValue(item, ConvertToBoolean(rd, i), null);
+ prop.SetValue(item, ConvertToBoolean(rd, i), null);
else if (prop.PropertyType == typeof(DateTime))
- prop.SetValue(item, ConvertToDateTime(rd, i), null);
+ prop.SetValue(item, ConvertToDateTime(rd, i), null);
}
return item;
diff --git a/Duplicati/Server/Runner.cs b/Duplicati/Server/Runner.cs
index 56bb6abb0..43bdbe746 100644
--- a/Duplicati/Server/Runner.cs
+++ b/Duplicati/Server/Runner.cs
@@ -942,11 +942,11 @@ namespace Duplicati.Server
if (filters == null || filters.Length == 0)
return null;
- return
+ return
(from n in filters
- orderby n.Order
- let exp = Environment.ExpandEnvironmentVariables(n.Expression)
- select (Duplicati.Library.Utility.IFilter)(new Duplicati.Library.Utility.FilterExpression(exp, n.Include)))
+ orderby n.Order
+ let exp = Environment.ExpandEnvironmentVariables(n.Expression)
+ select (Duplicati.Library.Utility.IFilter)(new Duplicati.Library.Utility.FilterExpression(exp, n.Include)))
.Aggregate((a, b) => Duplicati.Library.Utility.FilterExpression.Combine(a, b));
}
}
diff --git a/Duplicati/Server/SingleInstance.cs b/Duplicati/Server/SingleInstance.cs
index 28d154ca2..bed2debec 100644
--- a/Duplicati/Server/SingleInstance.cs
+++ b/Duplicati/Server/SingleInstance.cs
@@ -251,8 +251,12 @@ namespace Duplicati.Server
List<string> args = new List<string>();
using (System.IO.StreamReader sr = new System.IO.StreamReader(Platform.IsClientPosix ? UnixSupport.File.OpenExclusive(e.FullPath, System.IO.FileAccess.ReadWrite) : new System.IO.FileStream(e.FullPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None)))
- while(!sr.EndOfStream)
- args.Add(sr.ReadLine());
+ {
+ while (!sr.EndOfStream)
+ {
+ args.Add(sr.ReadLine());
+ }
+ }
commandline = args.ToArray();
diff --git a/Duplicati/Server/WebServer/RESTHandler.cs b/Duplicati/Server/WebServer/RESTHandler.cs
index 847545870..b09b78378 100644
--- a/Duplicati/Server/WebServer/RESTHandler.cs
+++ b/Duplicati/Server/WebServer/RESTHandler.cs
@@ -130,94 +130,98 @@ namespace Duplicati.Server.WebServer
{
var ci = ParseRequestCulture(info);
- using ( Library.Localization.LocalizationService.TemporaryContext(ci))
- try
+ using (Library.Localization.LocalizationService.TemporaryContext(ci))
{
- if (ci != null)
- info.Response.AddHeader("Content-Language", ci.Name);
+ try
+ {
+ if (ci != null)
+ info.Response.AddHeader("Content-Language", ci.Name);
- IRESTMethod mod;
- _modules.TryGetValue(module, out mod);
+ IRESTMethod mod;
+ _modules.TryGetValue(module, out mod);
- if (mod == null)
- {
- info.Response.Status = System.Net.HttpStatusCode.NotFound;
- info.Response.Reason = "No such module";
- }
- else if (method == HttpServer.Method.Get && mod is IRESTMethodGET get)
- {
- if (info.Request.Form != HttpServer.HttpForm.EmptyForm)
+ if (mod == null)
+ {
+ info.Response.Status = System.Net.HttpStatusCode.NotFound;
+ info.Response.Reason = "No such module";
+ }
+ else if (method == HttpServer.Method.Get && mod is IRESTMethodGET get)
{
- if (info.Request.QueryString == HttpServer.HttpInput.Empty)
+ if (info.Request.Form != HttpServer.HttpForm.EmptyForm)
{
- var r = info.Request.GetType().GetField("_queryString", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- r.SetValue(info.Request, new HttpServer.HttpInput("formdata"));
+ if (info.Request.QueryString == HttpServer.HttpInput.Empty)
+ {
+ var r = info.Request.GetType().GetField("_queryString", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
+ r.SetValue(info.Request, new HttpServer.HttpInput("formdata"));
+ }
+
+ foreach (HttpServer.HttpInputItem v in info.Request.Form)
+ if (!info.Request.QueryString.Contains(v.Name))
+ info.Request.QueryString.Add(v.Name, v.Value);
}
- foreach(HttpServer.HttpInputItem v in info.Request.Form)
- if (!info.Request.QueryString.Contains(v.Name))
- info.Request.QueryString.Add(v.Name, v.Value);
+ get.GET(key, info);
}
- get.GET(key, info);
- }
- else if (method == HttpServer.Method.Put && mod is IRESTMethodPUT put)
- put.PUT(key, info);
- else if (method == HttpServer.Method.Post && mod is IRESTMethodPOST post)
- {
- if (info.Request.Form == HttpServer.HttpForm.EmptyForm || info.Request.Form == HttpServer.HttpInput.Empty)
+ else if (method == HttpServer.Method.Put && mod is IRESTMethodPUT put)
+ put.PUT(key, info);
+ else if (method == HttpServer.Method.Post && mod is IRESTMethodPOST post)
{
- var r = info.Request.GetType().GetMethod("AssignForm", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, new Type[] { typeof(HttpServer.HttpForm) }, null);
- r.Invoke(info.Request, new object[] { new HttpServer.HttpForm(info.Request.QueryString) });
+ if (info.Request.Form == HttpServer.HttpForm.EmptyForm || info.Request.Form == HttpServer.HttpInput.Empty)
+ {
+ var r = info.Request.GetType().GetMethod("AssignForm", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, new Type[] {typeof(HttpServer.HttpForm)}, null);
+ r.Invoke(info.Request, new object[] {new HttpServer.HttpForm(info.Request.QueryString)});
+ }
+ else
+ {
+ foreach (HttpServer.HttpInputItem v in info.Request.QueryString)
+ if (!info.Request.Form.Contains(v.Name))
+ info.Request.Form.Add(v.Name, v.Value);
+ }
+
+ post.POST(key, info);
}
+ else if (method == HttpServer.Method.Delete && mod is IRESTMethodDELETE delete)
+ delete.DELETE(key, info);
+ else if (method == "PATCH" && mod is IRESTMethodPATCH patch)
+ patch.PATCH(key, info);
else
{
- foreach(HttpServer.HttpInputItem v in info.Request.QueryString)
- if (!info.Request.Form.Contains(v.Name))
- info.Request.Form.Add(v.Name, v.Value);
+ info.Response.Status = System.Net.HttpStatusCode.MethodNotAllowed;
+ info.Response.Reason = "Method is not allowed";
}
- post.POST(key, info);
}
- else if (method == HttpServer.Method.Delete && mod is IRESTMethodDELETE delete)
- delete.DELETE(key, info);
- else if (method == "PATCH" && mod is IRESTMethodPATCH patch)
- patch.PATCH(key, info);
- else
+ catch (Exception ex)
{
- info.Response.Status = System.Net.HttpStatusCode.MethodNotAllowed;
- info.Response.Reason = "Method is not allowed";
- }
- }
- catch(Exception ex)
- {
- Program.DataConnection.LogError("", string.Format("Request for {0} gave error", info.Request.Uri), ex);
- Console.WriteLine(ex);
+ Program.DataConnection.LogError("", string.Format("Request for {0} gave error", info.Request.Uri), ex);
+ Console.WriteLine(ex);
- try
- {
- if (!info.Response.HeadersSent)
+ try
{
- info.Response.Status = System.Net.HttpStatusCode.InternalServerError;
- info.Response.Reason = "Error";
- info.Response.ContentType = "text/plain";
-
- var wex = ex;
- while (wex is System.Reflection.TargetInvocationException && wex.InnerException != wex)
- wex = wex.InnerException;
-
- info.BodyWriter.WriteJsonObject(new
+ if (!info.Response.HeadersSent)
{
- Message = wex.Message,
- Type = wex.GetType().Name,
- #if DEBUG
- Stacktrace = wex.ToString()
- #endif
- });
- info.BodyWriter.Flush();
+ info.Response.Status = System.Net.HttpStatusCode.InternalServerError;
+ info.Response.Reason = "Error";
+ info.Response.ContentType = "text/plain";
+
+ var wex = ex;
+ while (wex is System.Reflection.TargetInvocationException && wex.InnerException != wex)
+ wex = wex.InnerException;
+
+ info.BodyWriter.WriteJsonObject(new
+ {
+ Message = wex.Message,
+ Type = wex.GetType().Name,
+#if DEBUG
+ Stacktrace = wex.ToString()
+#endif
+ });
+ info.BodyWriter.Flush();
+ }
+ }
+ catch (Exception flex)
+ {
+ Program.DataConnection.LogError("", "Reporting error gave error", flex);
}
- }
- catch (Exception flex)
- {
- Program.DataConnection.LogError("", "Reporting error gave error", flex);
}
}
}