Skip to content

Commit 1f17953

Browse files
committed
Minor cleanups
1 parent 13b3b55 commit 1f17953

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

Protest/Database/ContactsJsonConverter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public override void Write(Utf8JsonWriter writer, Database value, JsonSerializer
4444

4545
writer.WriteStartObject();
4646

47-
if (title?.value?.Length > 0) writer.WriteString(_title, title?.value ?? String.Empty);
48-
if (name?.Length > 0) writer.WriteString(_name, name);
49-
if (department?.value?.Length > 0) writer.WriteString(_department, department?.value ?? String.Empty);
47+
if (title?.value?.Length > 0) writer.WriteString(_title, title.value);
48+
if (name?.Length > 0) writer.WriteString(_name, name);
49+
if (department?.value?.Length > 0) writer.WriteString(_department, department.value);
5050

51-
if (email?.value?.Length > 0) writer.WriteString(_email, email?.value ?? String.Empty);
52-
if (telephoneNumber?.value?.Length > 0) writer.WriteString(_telephone, telephoneNumber?.value ?? String.Empty);
53-
if (mobileNumber?.value?.Length > 0) writer.WriteString(_mobile, mobileNumber?.value ?? String.Empty);
51+
if (email?.value?.Length > 0) writer.WriteString(_email, email.value);
52+
if (telephoneNumber?.value?.Length > 0) writer.WriteString(_telephone, telephoneNumber.value);
53+
if (mobileNumber?.value?.Length > 0) writer.WriteString(_mobile, mobileNumber.value);
5454

5555
writer.WriteEndObject();
5656
}

Protest/Tasks/Issues.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,8 @@ public static bool CheckDiskSpaceLifeline(Database.Entry device, string host, ou
624624
double slope = (n * sumXY - sumX * sumY) / (n * sumX2 - sumX * sumX);
625625
double intercept = (sumY - slope * sumX) / n;
626626

627-
if (slope == 0d) { continue; }
627+
//check if slop is close to 0
628+
if (Math.Abs(slope) < 1e-9) continue;
628629

629630
double currentTime = (double)(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - firstTimestamp);
630631
double predictedTime = (DISK_SPACE_THRESHOLD - intercept) / slope;

Protest/Tools/IpDiscovery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ private static void ParseMdnsResponse(ConcurrentDictionary<string, HostEntry> di
542542
else if (answer[j].type == Protocols.Dns.RecordType.SRV) {
543543
string[] split = answer[j].answerString.Split(':');
544544
if (split.Length >= 2) {
545-
hostname = split[0].EndsWith(".local") ? split[0][..^6] : hostname = split[0];
545+
hostname = split[0].EndsWith(".local") ? split[0][..^6] : split[0];
546546

547547
if (ushort.TryParse(split[1], out ushort port) && port > 0) {
548548
if (services.Length > 0) services.Append(',');

Protest/Tools/Topology.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal static async void WebSocketHandler(HttpListenerContext ctx) {
7373
}
7474

7575
string sessionId = ctx.Request.Cookies["sessionid"]?.Value ?? null;
76-
string origin = IPAddress.IsLoopback(ctx.Request.RemoteEndPoint.Address) ? "loopback" : Auth.GetUsername(sessionId);
76+
//string origin = IPAddress.IsLoopback(ctx.Request.RemoteEndPoint.Address) ? "loopback" : Auth.GetUsername(sessionId);
7777

7878
byte[] buffer = new byte[1024];
7979
WebSocketReceiveResult targetResult = await ws.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);

0 commit comments

Comments
 (0)