diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-11-22 18:36:31 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-22 18:36:31 -0600 |
| commit | 47490e366b5bc4b2a1679fba50655697afbe7137 (patch) | |
| tree | ae98bb4fb66d20e5fecd69267bcbb17d80c4986b /src/slskd/Core | |
| parent | 2e073014a003fc4e972a9a2677fccd3d30074cd2 (diff) | |
| parent | 6ba7311d48b95ca75f49b3b28c1a8db810f87fe1 (diff) | |
| download | slskd-47490e366b5bc4b2a1679fba50655697afbe7137.tar.gz | |
Merge branch 'master' into dependabot/npm_and_yarn/src/web/axios-0.30.2
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/Data/Migrations/Z07062025_TransferIndexesMigration.cs | 4 | ||||
| -rw-r--r-- | src/slskd/Core/Data/SqlitePragmaInterceptor.cs | 55 | ||||
| -rw-r--r-- | src/slskd/Core/Extensions.cs | 6 | ||||
| -rw-r--r-- | src/slskd/Core/Options.cs | 35 |
4 files changed, 94 insertions, 6 deletions
diff --git a/src/slskd/Core/Data/Migrations/Z07062025_TransferIndexesMigration.cs b/src/slskd/Core/Data/Migrations/Z07062025_TransferIndexesMigration.cs index 9b3f14a8..8ae13734 100644 --- a/src/slskd/Core/Data/Migrations/Z07062025_TransferIndexesMigration.cs +++ b/src/slskd/Core/Data/Migrations/Z07062025_TransferIndexesMigration.cs @@ -41,8 +41,8 @@ public class Z07062025_TransferIndexesMigration : IMigration var idxes = SchemaInspector.GetDatabaseIndexes(ConnectionString); var txfers = idxes["Transfers"]; - var directionExists = txfers.Any(c => c.Name == "IDX_Transfers_Direction"); - var stateExists = txfers.Any(c => c.Name == "IDX_Transfers_State"); + var directionExists = txfers.Any(c => c.Name.Equals("IDX_Transfers_Direction", StringComparison.OrdinalIgnoreCase)); + var stateExists = txfers.Any(c => c.Name.Equals("IDX_Transfers_State", StringComparison.OrdinalIgnoreCase)); if (directionExists && stateExists) { diff --git a/src/slskd/Core/Data/SqlitePragmaInterceptor.cs b/src/slskd/Core/Data/SqlitePragmaInterceptor.cs new file mode 100644 index 00000000..b32982b1 --- /dev/null +++ b/src/slskd/Core/Data/SqlitePragmaInterceptor.cs @@ -0,0 +1,55 @@ +// <copyright file="SqlitePragmaInterceptor.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +namespace slskd +{ + using System.Data.Common; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Data.Sqlite; + using Microsoft.EntityFrameworkCore.Diagnostics; + + /// <summary> + /// Intercepts SQLite database connections to set PRAGMAs immediately after opening. + /// </summary> + public class SqliteConnectionOpenedInterceptor : DbConnectionInterceptor + { + public override void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData) + { + if (connection is SqliteConnection) + { + using var cmd = connection.CreateCommand(); + cmd.CommandText = "PRAGMA synchronous=1;"; + cmd.ExecuteNonQuery(); + } + + base.ConnectionOpened(connection, eventData); + } + + public override async Task ConnectionOpenedAsync(DbConnection connection, ConnectionEndEventData eventData, CancellationToken cancellationToken = default) + { + if (connection is SqliteConnection) + { + using var cmd = connection.CreateCommand(); + cmd.CommandText = "PRAGMA synchronous=1;"; + await cmd.ExecuteNonQueryAsync(cancellationToken); + } + + await base.ConnectionOpenedAsync(connection, eventData, cancellationToken); + } + } +} diff --git a/src/slskd/Core/Extensions.cs b/src/slskd/Core/Extensions.cs index 65942180..db75cc9c 100644 --- a/src/slskd/Core/Extensions.cs +++ b/src/slskd/Core/Extensions.cs @@ -51,7 +51,7 @@ namespace slskd /// <param name="connectTimeout">The connection timeout, in milliseconds, for client and peer TCP connections.</param> /// <param name="inactivityTimeout">The inactivity timeout, in milliseconds, for peer TCP connections.</param> /// <param name="proxyOptions">Optional SOCKS 5 proxy configuration options.</param> - /// <param name="configureSocketAction"> + /// <param name="configureSocket"> /// The delegate invoked during instantiation to configure the server Socket instance. /// </param> /// <returns>The new instance.</returns> @@ -63,14 +63,14 @@ namespace slskd int? connectTimeout = null, int? inactivityTimeout = null, ProxyOptions proxyOptions = null, - Action<Socket> configureSocketAction = null) => new ConnectionOptions( + Action<Socket> configureSocket = null) => new ConnectionOptions( readBufferSize: readBufferSize ?? o.ReadBufferSize, writeBufferSize: writeBufferSize ?? o.WriteBufferSize, writeQueueSize: writeQueueSize ?? o.WriteQueueSize, connectTimeout: connectTimeout ?? o.ConnectTimeout, inactivityTimeout: inactivityTimeout ?? o.InactivityTimeout, proxyOptions: proxyOptions ?? o.ProxyOptions, - configureSocket: configureSocketAction ?? o.ConfigureSocket); + configureSocket: configureSocket ?? o.ConfigureSocket); /// <summary> /// Creates a new instance of <see cref="UserStatisticsState"/> from this instance of <see cref="UserStatistics"/>. diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 352d23e9..ec94afcb 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -418,6 +418,15 @@ namespace slskd public bool LogSQL { get; init; } = false; /// <summary> + /// Gets a value indicating whether to log unobserved Exceptions. + /// </summary> + [Argument(default, "log-unobserved-exceptions")] + [EnvironmentVariable("LOG_UNOBSERVED_EXCEPTIONS")] + [Description("log unobserved exceptions (caution: verbose)")] + [RequiresRestart] + public bool LogUnobservedExceptions { get; init; } = false; + + /// <summary> /// Gets a value indicating whether the application should run in experimental mode. /// </summary> [Argument(default, "experimental")] @@ -461,6 +470,22 @@ namespace slskd [EnvironmentVariable("OPTIMISTIC_RELAY_FILE_INFO")] [Description("use uploaded relay shares as source of truth for file existence and size")] public bool OptimisticRelayFileInfo { get; init; } = false; + + /// <summary> + /// Gets a value indicating whether SQLite cache sharing should be disabled (set to Private). + /// </summary> + [Argument(default, "no-sqlite-cache-sharing")] + [EnvironmentVariable("NO_SQLITE_CACHE_SHARING")] + [Description("disable SQLite cache sharing")] + public bool NoSqliteCacheSharing { get; init; } = false; + + /// <summary> + /// Gets a value indicating whether SQLite pooling should be disabled. + /// </summary> + [Argument(default, "no-sqlite-pooling")] + [EnvironmentVariable("NO_SQLITE_POOLING")] + [Description("disable SQLite pooling")] + public bool NoSqlitePooling { get; init; } = false; } /// <summary> @@ -1675,6 +1700,15 @@ namespace slskd [Description("connection inactivity timeout, in milliseconds")] [Range(1000, int.MaxValue)] public int Inactivity { get; init; } = 15000; + + /// <summary> + /// Gets the transfer connection timeout, in milliseconds. + /// </summary> + [Argument(default, "slsk-transfer-timeout")] + [EnvironmentVariable("SLSK_TRANSFER_TIMEOUT")] + [Description("transfer connection timeout, in milliseconds")] + [Range(30_000, int.MaxValue)] + public int Transfer { get; init; } = 60000; } /// <summary> @@ -1812,7 +1846,6 @@ namespace slskd [Argument(default, "http-socket")] [EnvironmentVariable("HTTP_SOCKET")] [Description("HTTP listen unix domain socket (UDS) path for web UI")] - [FileDoesNotExist] [AbsoluteFilePath] [RequiresRestart] public string Socket { get; init; } |
