From 07952c6ebe125120b848e0e9d5de85644185d9a5 Mon Sep 17 00:00:00 2001
From: Terry Wilson <103469370+dkschruteBeets@users.noreply.github.com>
Date: Sun, 2 Mar 2025 16:55:19 -0700
Subject: feat: add profile picture support
---
src/slskd/Application.cs | 8 +++++--
src/slskd/Core/Options.cs | 10 +++++++-
src/slskd/Program.cs | 5 ++++
src/slskd/Users/IUserService.cs | 7 ++++++
src/slskd/Users/UserService.cs | 51 ++++++++++++++++++++++++++++++++++++++++-
5 files changed, 77 insertions(+), 4 deletions(-)
(limited to 'src')
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 791cf245..6a539fa9 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1662,13 +1662,16 @@ namespace slskd
/// A Task resolving the UserInfo instance.
private async Task UserInfoResolver(string username, IPEndPoint endpoint)
{
+ var profilePicture = Users.GetProfilePicture(Options.Soulseek.ProfilePicture);
+
if (Users.IsBlacklisted(username, endpoint.Address))
{
return new UserInfo(
description: Options.Soulseek.Description,
uploadSlots: 0,
queueLength: int.MaxValue,
- hasFreeUploadSlot: false);
+ hasFreeUploadSlot: false,
+ picture: profilePicture);
}
try
@@ -1692,7 +1695,8 @@ namespace slskd
description: Options.Soulseek.Description,
uploadSlots: group.Slots,
queueLength: forecastedPosition,
- hasFreeUploadSlot: forecastedPosition == 0);
+ hasFreeUploadSlot: forecastedPosition == 0,
+ picture: profilePicture);
return info;
}
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index 266d04aa..68856b36 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1531,6 +1531,14 @@ namespace slskd
[Description("user description for the Soulseek network")]
public string Description { get; init; } = "A slskd user. https://github.com/slskd/slskd";
+ ///
+ /// Gets the file path for the user's profile picture.
+ ///
+ [Argument(default, "slsk-profile-picture")]
+ [EnvironmentVariable("SLSK_PROFILE_PICTURE")]
+ [Description("path to the user's profile picture file")]
+ public string ProfilePicture { get; init; } = Program.DefaultProfilePicturePath;
+
///
/// Gets the local IP address on which to listen for incoming connections.
///
@@ -1656,7 +1664,7 @@ namespace slskd
[EnvironmentVariable("SLSK_INACTIVITY_TIMEOUT")]
[Description("connection inactivity timeout, in milliseconds")]
[Range(1000, int.MaxValue)]
- public int Inactivity { get; init; } = 15000;
+ public int Inactivity { get; init; } = 30000;
}
///
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index b7fa47d2..c2b28cc9 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -202,6 +202,11 @@ namespace slskd
///
public static string DefaultIncompleteDirectory { get; private set; }
+ ///
+ /// Gets the default profile picture path.
+ ///
+ public static string DefaultProfilePicturePath { get; private set; } = Path.Combine(AppContext.BaseDirectory, "slsk-profile-picture.jpg");
+
///
/// Gets the path where application logs are saved.
///
diff --git a/src/slskd/Users/IUserService.cs b/src/slskd/Users/IUserService.cs
index 75afd442..e84d7461 100644
--- a/src/slskd/Users/IUserService.cs
+++ b/src/slskd/Users/IUserService.cs
@@ -152,5 +152,12 @@ namespace slskd.Users
/// The username of the peer.
/// The operation context.
Task WatchAsync(string username);
+
+ ///
+ /// Gets the profile picture as a byte array if it exists.
+ ///
+ /// The profile picture path to resolve.
+ /// The profile picture as a byte array if it exists and can be read, null otherwise.
+ byte[] GetProfilePicture(string profilePicture);
}
}
\ No newline at end of file
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs
index ead1d812..d634704a 100644
--- a/src/slskd/Users/UserService.cs
+++ b/src/slskd/Users/UserService.cs
@@ -19,13 +19,16 @@ using Microsoft.Extensions.Options;
namespace slskd.Users
{
+ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+ using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using NetTools;
using Serilog;
+ using slskd.Files;
using Soulseek;
///
@@ -65,16 +68,21 @@ namespace slskd.Users
///
public class UserService : IUserService
{
+ private readonly FileService fileService;
+
///
/// Initializes a new instance of the class.
///
///
///
+ ///
public UserService(
ISoulseekClient soulseekClient,
- IOptionsMonitor optionsMonitor)
+ IOptionsMonitor optionsMonitor,
+ FileService fileService)
{
Client = soulseekClient;
+ this.fileService = fileService;
OptionsMonitor = optionsMonitor;
OptionsMonitor.OnChange(options => Configure(options));
@@ -146,6 +154,47 @@ namespace slskd.Users
private ConcurrentDictionary UserDictionary { get; set; } = new ConcurrentDictionary();
private ConcurrentDictionary WatchedUsernamesDictionary { get; set; } = new ConcurrentDictionary();
+ ///
+ /// Gets the profile picture as a byte array if it exists.
+ ///
+ /// The profile picture path to resolve.
+ /// The profile picture as a byte array if it exists and can be read, null otherwise.
+ public byte[] GetProfilePicture(string profilePicture)
+ {
+ if (string.IsNullOrWhiteSpace(profilePicture))
+ {
+ Log.Warning("Profile picture path is not set");
+ return null;
+ }
+
+ try
+ {
+ // Ensure the path is relative to the app directory for security
+ var fullPath = Path.GetFullPath(
+ Path.Combine(AppContext.BaseDirectory, profilePicture));
+
+ var fileInfo = fileService.ResolveFileInfo(fullPath);
+ if (!fileInfo.Exists)
+ {
+ Log.Warning("Profile picture '{Path}' not found", profilePicture);
+ return null;
+ }
+
+ // Read the file into a byte array
+ return System.IO.File.ReadAllBytes(fileInfo.FullName);
+ }
+ catch (UnauthorizedException ex)
+ {
+ Log.Warning(ex, "Access to profile picture '{Path}' was denied", profilePicture);
+ return null;
+ }
+ catch (IOException ex)
+ {
+ Log.Warning(ex, "Failed to read profile picture '{Path}'", profilePicture);
+ return null;
+ }
+ }
+
///
/// Gets the name of the group for the specified .
///
--
cgit v1.2.3
From 01e41848bdf9e40930ea4b60f8f4f3fbe8ea4037 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Sat, 5 Apr 2025 17:11:39 -0500
Subject: set inactivity back to 15s
---
config/slskd.example.yml | 2 +-
src/slskd/Core/Options.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/config/slskd.example.yml b/config/slskd.example.yml
index 69725415..40ddcc5e 100644
--- a/config/slskd.example.yml
+++ b/config/slskd.example.yml
@@ -204,7 +204,7 @@
# connection:
# timeout:
# connect: 10000
-# inactivity: 30000
+# inactivity: 15000
# buffer:
# read: 16384
# write: 16384
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index 68856b36..aeba446c 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1664,7 +1664,7 @@ namespace slskd
[EnvironmentVariable("SLSK_INACTIVITY_TIMEOUT")]
[Description("connection inactivity timeout, in milliseconds")]
[Range(1000, int.MaxValue)]
- public int Inactivity { get; init; } = 30000;
+ public int Inactivity { get; init; } = 15000;
}
///
--
cgit v1.2.3
From 4b56b8eb282a9a32408b2b02c0e758f7bea23af2 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Sat, 5 Apr 2025 17:12:27 -0500
Subject: tweak picture option
---
src/slskd/Core/Options.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'src')
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index aeba446c..22963eba 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1534,10 +1534,10 @@ namespace slskd
///
/// Gets the file path for the user's profile picture.
///
- [Argument(default, "slsk-profile-picture")]
- [EnvironmentVariable("SLSK_PROFILE_PICTURE")]
- [Description("path to the user's profile picture file")]
- public string ProfilePicture { get; init; } = Program.DefaultProfilePicturePath;
+ [Argument(default, "slsk-picture")]
+ [EnvironmentVariable("SLSK_PICTURE")]
+ [Description("user picture for the Soulseek network")]
+ public string Picture { get; init; } = null;
///
/// Gets the local IP address on which to listen for incoming connections.
--
cgit v1.2.3
From 7f2cc8a2270340a17a46366e200fe832fd5137c1 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Sat, 5 Apr 2025 17:13:47 -0500
Subject: ensure file exists if specified
---
src/slskd/Core/Options.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'src')
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index 22963eba..cc662444 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1537,6 +1537,7 @@ namespace slskd
[Argument(default, "slsk-picture")]
[EnvironmentVariable("SLSK_PICTURE")]
[Description("user picture for the Soulseek network")]
+ [FileExists(FileAccess.Read)]
public string Picture { get; init; } = null;
///
--
cgit v1.2.3
From 1a8c5cc0ea17d659e56a3b7d266939a6f74f03fc Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Sun, 6 Apr 2025 17:25:22 -0500
Subject: remove unused default picture path
---
src/slskd/Program.cs | 5 -----
1 file changed, 5 deletions(-)
(limited to 'src')
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index c2b28cc9..b7fa47d2 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -202,11 +202,6 @@ namespace slskd
///
public static string DefaultIncompleteDirectory { get; private set; }
- ///
- /// Gets the default profile picture path.
- ///
- public static string DefaultProfilePicturePath { get; private set; } = Path.Combine(AppContext.BaseDirectory, "slsk-profile-picture.jpg");
-
///
/// Gets the path where application logs are saved.
///
--
cgit v1.2.3
From 831e9ce49abbcc64a7b75c6fb2c90ad20b233e00 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Sun, 6 Apr 2025 17:25:46 -0500
Subject: formatting/docs
---
src/slskd/Application.cs | 3 ++-
tests/slskd.Tests.Unit/Users/UserServiceTests.cs | 16 ++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
(limited to 'src')
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index acfecdbf..1e71652c 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1662,7 +1662,7 @@ namespace slskd
/// A Task resolving the UserInfo instance.
private async Task UserInfoResolver(string username, IPEndPoint endpoint)
{
- var profilePicture = Users.GetProfilePicture(Options.Soulseek.ProfilePicture);
+ var profilePicture = Users.GetProfilePicture(Options.Soulseek.Picture);
if (Users.IsBlacklisted(username, endpoint.Address))
{
@@ -1691,6 +1691,7 @@ 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,
diff --git a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
index 28f54629..205ff0e2 100644
--- a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
+++ b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
@@ -130,9 +130,9 @@
public void Returns_Null_When_Path_Is_NullOrWhitespace(string path)
{
var (service, _) = GetFixture();
-
+
var result = service.GetProfilePicture(path);
-
+
Assert.Null(result);
}
@@ -141,9 +141,9 @@
{
const string nonExistentPath = "nonexistent-file.jpg";
var (service, _) = GetFixture();
-
+
var result = service.GetProfilePicture(nonExistentPath);
-
+
Assert.Null(result);
}
@@ -155,11 +155,11 @@
{
// Write some test data to the temp file
System.IO.File.WriteAllBytes(tempFile, new byte[] { 1, 2, 3, 4, 5 });
-
+
var (service, _) = GetFixture();
-
+
var result = service.GetProfilePicture(tempFile);
-
+
Assert.NotNull(result);
Assert.Equal(new byte[] { 1, 2, 3, 4, 5 }, result);
}
@@ -174,7 +174,7 @@
}
}
- private static (UserService governor, Mocks mocks) GetFixture(Options options = null)
+ private static (UserService service, Mocks mocks) GetFixture(Options options = null)
{
var mocks = new Mocks(options);
var service = new UserService(
--
cgit v1.2.3
From 21da11dfae33529d2672da06a8fa52b5343b5239 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Mon, 7 Apr 2025 12:33:22 -0500
Subject: simplify fetch of picture bytes
---
src/slskd/Application.cs | 15 +++++--
src/slskd/Users/IUserService.cs | 7 ---
src/slskd/Users/UserService.cs | 49 +--------------------
tests/slskd.Tests.Unit/Users/UserServiceTests.cs | 56 +-----------------------
4 files changed, 14 insertions(+), 113 deletions(-)
(limited to 'src')
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 1e71652c..4ed9d092 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1662,7 +1662,16 @@ namespace slskd
/// A Task resolving the UserInfo instance.
private async Task UserInfoResolver(string username, IPEndPoint endpoint)
{
- var profilePicture = Users.GetProfilePicture(Options.Soulseek.Picture);
+ byte[] pictureBytes = null;
+
+ try
+ {
+ pictureBytes = await System.IO.File.ReadAllBytesAsync(Options.Soulseek.Picture);
+ }
+ catch (Exception ex)
+ {
+ Log.Warning("Failed to read Soulseek picture {Picture}: {Message}", Options.Soulseek.Picture, ex.Message);
+ }
if (Users.IsBlacklisted(username, endpoint.Address))
{
@@ -1671,7 +1680,7 @@ namespace slskd
uploadSlots: 0,
queueLength: int.MaxValue,
hasFreeUploadSlot: false,
- picture: profilePicture);
+ picture: pictureBytes);
}
try
@@ -1697,7 +1706,7 @@ namespace slskd
uploadSlots: group.Slots,
queueLength: forecastedPosition,
hasFreeUploadSlot: forecastedPosition == 0,
- picture: profilePicture);
+ picture: pictureBytes);
return info;
}
diff --git a/src/slskd/Users/IUserService.cs b/src/slskd/Users/IUserService.cs
index e84d7461..75afd442 100644
--- a/src/slskd/Users/IUserService.cs
+++ b/src/slskd/Users/IUserService.cs
@@ -152,12 +152,5 @@ namespace slskd.Users
/// The username of the peer.
/// The operation context.
Task WatchAsync(string username);
-
- ///
- /// Gets the profile picture as a byte array if it exists.
- ///
- /// The profile picture path to resolve.
- /// The profile picture as a byte array if it exists and can be read, null otherwise.
- byte[] GetProfilePicture(string profilePicture);
}
}
\ No newline at end of file
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs
index d634704a..55b02134 100644
--- a/src/slskd/Users/UserService.cs
+++ b/src/slskd/Users/UserService.cs
@@ -68,22 +68,16 @@ namespace slskd.Users
///
public class UserService : IUserService
{
- private readonly FileService fileService;
-
///
/// Initializes a new instance of the class.
///
///
///
- ///
public UserService(
ISoulseekClient soulseekClient,
- IOptionsMonitor optionsMonitor,
- FileService fileService)
+ IOptionsMonitor optionsMonitor)
{
Client = soulseekClient;
- this.fileService = fileService;
-
OptionsMonitor = optionsMonitor;
OptionsMonitor.OnChange(options => Configure(options));
@@ -154,47 +148,6 @@ namespace slskd.Users
private ConcurrentDictionary UserDictionary { get; set; } = new ConcurrentDictionary();
private ConcurrentDictionary WatchedUsernamesDictionary { get; set; } = new ConcurrentDictionary();
- ///
- /// Gets the profile picture as a byte array if it exists.
- ///
- /// The profile picture path to resolve.
- /// The profile picture as a byte array if it exists and can be read, null otherwise.
- public byte[] GetProfilePicture(string profilePicture)
- {
- if (string.IsNullOrWhiteSpace(profilePicture))
- {
- Log.Warning("Profile picture path is not set");
- return null;
- }
-
- try
- {
- // Ensure the path is relative to the app directory for security
- var fullPath = Path.GetFullPath(
- Path.Combine(AppContext.BaseDirectory, profilePicture));
-
- var fileInfo = fileService.ResolveFileInfo(fullPath);
- if (!fileInfo.Exists)
- {
- Log.Warning("Profile picture '{Path}' not found", profilePicture);
- return null;
- }
-
- // Read the file into a byte array
- return System.IO.File.ReadAllBytes(fileInfo.FullName);
- }
- catch (UnauthorizedException ex)
- {
- Log.Warning(ex, "Access to profile picture '{Path}' was denied", profilePicture);
- return null;
- }
- catch (IOException ex)
- {
- Log.Warning(ex, "Failed to read profile picture '{Path}'", profilePicture);
- return null;
- }
- }
-
///
/// Gets the name of the group for the specified .
///
diff --git a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
index 205ff0e2..8581a966 100644
--- a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
+++ b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
@@ -121,66 +121,12 @@
}
}
- public class GetProfilePicture
- {
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- [InlineData(" ")]
- public void Returns_Null_When_Path_Is_NullOrWhitespace(string path)
- {
- var (service, _) = GetFixture();
-
- var result = service.GetProfilePicture(path);
-
- Assert.Null(result);
- }
-
- [Fact]
- public void Returns_Null_When_File_Does_Not_Exist()
- {
- const string nonExistentPath = "nonexistent-file.jpg";
- var (service, _) = GetFixture();
-
- var result = service.GetProfilePicture(nonExistentPath);
-
- Assert.Null(result);
- }
-
- [Fact]
- public void Returns_File_Bytes_When_File_Exists()
- {
- var tempFile = Path.GetTempFileName();
- try
- {
- // Write some test data to the temp file
- System.IO.File.WriteAllBytes(tempFile, new byte[] { 1, 2, 3, 4, 5 });
-
- var (service, _) = GetFixture();
-
- var result = service.GetProfilePicture(tempFile);
-
- Assert.NotNull(result);
- Assert.Equal(new byte[] { 1, 2, 3, 4, 5 }, result);
- }
- finally
- {
- // Clean up
- if (System.IO.File.Exists(tempFile))
- {
- System.IO.File.Delete(tempFile);
- }
- }
- }
- }
-
private static (UserService service, Mocks mocks) GetFixture(Options options = null)
{
var mocks = new Mocks(options);
var service = new UserService(
mocks.SoulseekClient.Object,
- mocks.OptionsMonitor,
- mocks.FileService);
+ mocks.OptionsMonitor);
return (service, mocks);
}
--
cgit v1.2.3
From f174c680f6133580033d9baaff71d40bce43e753 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Mon, 7 Apr 2025 12:33:36 -0500
Subject: leave some notes
---
src/slskd/Application.cs | 4 ++++
src/slskd/Users/UserService.cs | 3 ---
tests/slskd.Tests.Unit/Users/UserServiceTests.cs | 4 ----
3 files changed, 4 insertions(+), 7 deletions(-)
(limited to 'src')
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 4ed9d092..f13a1c9b 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1666,10 +1666,14 @@ namespace slskd
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);
}
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs
index 55b02134..2e312f69 100644
--- a/src/slskd/Users/UserService.cs
+++ b/src/slskd/Users/UserService.cs
@@ -19,16 +19,13 @@ using Microsoft.Extensions.Options;
namespace slskd.Users
{
- using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
- using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using NetTools;
using Serilog;
- using slskd.Files;
using Soulseek;
///
diff --git a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
index 8581a966..ca45d5b9 100644
--- a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
+++ b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs
@@ -1,10 +1,8 @@
namespace slskd.Tests.Unit.Users
{
using System.Collections.Generic;
- using System.IO;
using AutoFixture.Xunit2;
using Moq;
- using slskd.Files;
using slskd.Users;
using Soulseek;
using Xunit;
@@ -136,12 +134,10 @@
public Mocks(Options options = null)
{
OptionsMonitor = new TestOptionsMonitor(options ?? new Options());
- FileService = new FileService(OptionsMonitor);
}
public Mock SoulseekClient { get; } = new Mock();
public TestOptionsMonitor OptionsMonitor { get; init; }
- public FileService FileService { get; init; }
}
}
}
--
cgit v1.2.3
From 8571f94db79d118bf5a2c62a713bb96e5deb9330 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Mon, 7 Apr 2025 13:59:25 -0500
Subject: docs
---
docs/config.md | 2 ++
src/slskd/Users/UserService.cs | 1 +
2 files changed, 3 insertions(+)
(limited to 'src')
diff --git a/docs/config.md b/docs/config.md
index 92798196..a582c783 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -683,11 +683,13 @@ soulseek:
| Command-Line | Environment Variable | Description |
| -------------------- | -------------------------- | --------------------------------------------- |
| `--slsk-description` | `SLSKD_SLSK_DESCRIPTION` | The user description for the Soulseek network |
+| `--slsk-picture` | `SLSKD_SLSK_PICTURE` | The user picture for the Soulseek network |
#### **YAML**
```yaml
soulseek:
description: A slskd user. https://github.com/slskd/slskd
+ picture: path/to/slsk-profile-picture.jpg
```
## Connection Options
diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs
index 2e312f69..ead1d812 100644
--- a/src/slskd/Users/UserService.cs
+++ b/src/slskd/Users/UserService.cs
@@ -75,6 +75,7 @@ namespace slskd.Users
IOptionsMonitor optionsMonitor)
{
Client = soulseekClient;
+
OptionsMonitor = optionsMonitor;
OptionsMonitor.OnChange(options => Configure(options));
--
cgit v1.2.3
From 8c98fc35ca41cf52e6af746e608926b516fe3ad8 Mon Sep 17 00:00:00 2001
From: JP Dillingham
Date: Mon, 7 Apr 2025 14:46:58 -0500
Subject: check for configured file before trying to read it
---
src/slskd/Application.cs | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
(limited to 'src')
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index f13a1c9b..9179987e 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1664,17 +1664,20 @@ namespace slskd
{
byte[] pictureBytes = null;
- try
+ if (!string.IsNullOrWhiteSpace(Options.Soulseek.Picture))
{
- // 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);
+ 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))
--
cgit v1.2.3