aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-08-28 21:28:32 -0500
committerJP Dillingham <jp@dillingham.me>2022-08-28 21:28:32 -0500
commitc7a8e442948b0454f3af26da87d8691d9ad6a805 (patch)
tree37c0b7a2d23bc8133834243740a5a34de36da9fb /src
parent1b235ba96a0e139f08561b74e29a8b8875f046af (diff)
downloadslskd-c7a8e442948b0454f3af26da87d8691d9ad6a805.tar.gz
remove temporary logging
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application.cs84
1 files changed, 38 insertions, 46 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index e9b00c6b..bd34d612 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -898,67 +898,59 @@ namespace slskd
/// <returns>A Task resolving a SearchResponse, or null.</returns>
private async Task<SearchResponse> SearchResponseResolver(string username, int token, SearchQuery query)
{
- try
- {
- Metrics.Search.RequestsReceived.Inc(1);
+ Metrics.Search.RequestsReceived.Inc(1);
- if (CompiledSearchResponseFilters.Any(filter => filter.IsMatch(query.SearchText)))
- {
- return null;
- }
-
- // sometimes clients send search queries consisting only of exclusions; drop them.
- // no other clients send search results for these, even though it is technically possible.
- if (!query.Terms.Any())
- {
- return null;
- }
+ if (CompiledSearchResponseFilters.Any(filter => filter.IsMatch(query.SearchText)))
+ {
+ return null;
+ }
- try
- {
- var sw = new Stopwatch();
- sw.Start();
+ // sometimes clients send search queries consisting only of exclusions; drop them.
+ // no other clients send search results for these, even though it is technically possible.
+ if (!query.Terms.Any())
+ {
+ return null;
+ }
- var results = await Shares.SearchAsync(query);
+ try
+ {
+ var sw = new Stopwatch();
+ sw.Start();
- sw.Stop();
+ var results = await Shares.SearchAsync(query);
- Metrics.Search.ResponseLatency.Observe(sw.ElapsedMilliseconds);
- Metrics.Search.CurrentResponseLatency.Update(sw.ElapsedMilliseconds);
+ sw.Stop();
- if (results.Any())
- {
- // make sure our average speed (as reported by the server) is reasonably up to date
- await RefreshUserStatistics();
+ Metrics.Search.ResponseLatency.Observe(sw.ElapsedMilliseconds);
+ Metrics.Search.CurrentResponseLatency.Update(sw.ElapsedMilliseconds);
- var forecastedPosition = Transfers.Uploads.Queue.ForecastPosition(username);
+ if (results.Any())
+ {
+ // make sure our average speed (as reported by the server) is reasonably up to date
+ await RefreshUserStatistics();
- Log.Information("[{Context}]: Sending {Count} records to {Username} for query '{Query}'", "SEARCH RESULT SENT", results.Count(), username, query.SearchText);
+ var forecastedPosition = Transfers.Uploads.Queue.ForecastPosition(username);
- Metrics.Search.ResponsesSent.Inc(1);
+ Log.Information("[{Context}]: Sending {Count} records to {Username} for query '{Query}'", "SEARCH RESULT SENT", results.Count(), username, query.SearchText);
- return new SearchResponse(
- Client.Username,
- token,
- uploadSpeed: State.CurrentValue.User.Statistics.AverageSpeed,
- freeUploadSlots: forecastedPosition == 0 ? 1 : 0,
- queueLength: forecastedPosition,
- fileList: results);
- }
+ Metrics.Search.ResponsesSent.Inc(1);
- // if no results, either return null or an instance of SearchResponse with a fileList of length 0 in either case, no
- // response will be sent to the requestor.
- return null;
- }
- catch (Exception ex)
- {
- Log.Warning(ex, "Failed to resolve search response: {Message}", ex.Message);
- throw;
+ return new SearchResponse(
+ Client.Username,
+ token,
+ uploadSpeed: State.CurrentValue.User.Statistics.AverageSpeed,
+ freeUploadSlots: forecastedPosition == 0 ? 1 : 0,
+ queueLength: forecastedPosition,
+ fileList: results);
}
+
+ // if no results, either return null or an instance of SearchResponse with a fileList of length 0 in either case, no
+ // response will be sent to the requestor.
+ return null;
}
catch (Exception ex)
{
- Console.WriteLine(ex);
+ Log.Warning(ex, "Failed to resolve search response: {Message}", ex.Message);
throw;
}
}