diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-05-03 17:53:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-03 17:53:30 -0500 |
| commit | a87b58ae5d09a127f7d5eb5d1908a3f083dfe1f7 (patch) | |
| tree | 6739f38224a4e5f649092fdd3cc6f3772b7d0270 /src/slskd/Application.cs | |
| parent | 207a645006f75a0fb96f2a1b6a72017f94d42c80 (diff) | |
| parent | 7b99d3339154972eed0f04beef5a91678e5a0efb (diff) | |
| download | slskd-a87b58ae5d09a127f7d5eb5d1908a3f083dfe1f7.tar.gz | |
Merge branch 'master' into migrations
Diffstat (limited to 'src/slskd/Application.cs')
| -rw-r--r-- | src/slskd/Application.cs | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index e5681442..2449e8e0 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -830,6 +830,12 @@ namespace slskd var logger = Loggers.GetOrAdd(source, Log.ForContext("Context", "Soulseek").ForContext("SubContext", source)); + if (args.IncludesException && OptionsAtStartup.Debug) + { + logger.Write(TranslateLogLevel(args.Level), exception: args.Exception, "{@Message}", args.Message); + return; + } + logger.Write(TranslateLogLevel(args.Level), "{@Message}", args.Message); } @@ -1662,13 +1668,32 @@ namespace slskd /// <returns>A Task resolving the UserInfo instance.</returns> private async Task<UserInfo> UserInfoResolver(string username, IPEndPoint endpoint) { + byte[] pictureBytes = null; + + if (!string.IsNullOrWhiteSpace(Options.Soulseek.Picture)) + { + try + { + // note: the Picture setting is validated at startup to ensure it exists and that + // it is readable + pictureBytes = await System.IO.File.ReadAllBytesAsync(Options.Soulseek.Picture); + } + catch (Exception ex) + { + // this isn't a serious enough problem to prevent us from continuing, so we'll just + // log a warning and continue, omitting the picture + Log.Warning("Failed to read Soulseek picture {Picture}: {Message}", Options.Soulseek.Picture, ex.Message); + } + } + if (Users.IsBlacklisted(username, endpoint.Address)) { return new UserInfo( description: Options.Soulseek.Description, uploadSlots: 0, queueLength: int.MaxValue, - hasFreeUploadSlot: false); + hasFreeUploadSlot: false, + picture: pictureBytes); } try @@ -1688,11 +1713,13 @@ namespace slskd // i want to know how many slots they have, which gives me an idea of how fast their // queue moves, and the length of the queue *ahead of me*, meaning how long i'd have to // wait until my first download starts. + // revisited 3 years later: why was it important to leave this comment?? var info = new UserInfo( description: Options.Soulseek.Description, uploadSlots: group.Slots, queueLength: forecastedPosition, - hasFreeUploadSlot: forecastedPosition == 0); + hasFreeUploadSlot: forecastedPosition == 0, + picture: pictureBytes); return info; } |
