aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-08-07 16:07:05 -0500
committerGitHub <noreply@github.com>2022-08-07 16:07:05 -0500
commit4ba81ad7d51cdbe2a1bb9fb055f7d941c6061876 (patch)
treedd8ea1392c4f61defc67b6436ee58be689b3991b /src/slskd/Program.cs
parent25c4abfc9428272eed0936d17c8a310653b21111 (diff)
parent80ecb0d03cf1da83e33dde6326365713b3d605e0 (diff)
downloadslskd-4ba81ad7d51cdbe2a1bb9fb055f7d941c6061876.tar.gz
Merge pull request #569 from slskd/transfers
Store transfers in a database (as opposed to in-memory)
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index f11132b4..5ed6bf80 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -15,6 +15,8 @@
// along with this program. If not, see https://www.gnu.org/licenses/.
// </copyright>
+using Microsoft.Extensions.Logging;
+
namespace slskd
{
using System;
@@ -60,6 +62,8 @@ namespace slskd
using slskd.Search.API;
using slskd.Shares;
using slskd.Transfers;
+ using slskd.Transfers.Downloads;
+ using slskd.Transfers.Uploads;
using slskd.Users;
using slskd.Validation;
using Soulseek;
@@ -449,8 +453,8 @@ namespace slskd
services.AddSingleton<IConnectionWatchdog, ConnectionWatchdog>();
services.AddDbContext<SearchDbContext>("search.db");
+ services.AddDbContext<TransfersDbContext>("transfers.db");
- services.AddSingleton<ITransferTracker, TransferTracker>();
services.AddSingleton<IBrowseTracker, BrowseTracker>();
services.AddSingleton<IConversationTracker, ConversationTracker>();
services.AddSingleton<IRoomTracker, RoomTracker>(_ => new RoomTracker(messageLimit: 250));
@@ -460,7 +464,10 @@ namespace slskd
services.AddSingleton<ISearchService, SearchService>();
services.AddSingleton<IUserService, UserService>();
services.AddSingleton<IRoomService, RoomService>();
+
services.AddSingleton<ITransferService, TransferService>();
+ services.AddSingleton<IDownloadService, DownloadService>();
+ services.AddSingleton<IUploadService, UploadService>();
services.AddSingleton<IFTPClientFactory, FTPClientFactory>();
services.AddSingleton<IFTPService, FTPService>();
@@ -785,13 +792,19 @@ namespace slskd
private static IServiceCollection AddDbContext<T>(this IServiceCollection services, string filename)
where T : DbContext
{
- Log.Debug($"Initializing database context {typeof(T).Name}");
+ Log.Debug("Initializing database context {Name}", typeof(T).Name);
try
{
- services.AddDbContextFactory<SearchDbContext>(options =>
+ services.AddDbContextFactory<T>(options =>
{
options.UseSqlite($"Data Source={Path.Combine(AppDirectory, "data", filename)}");
+
+ // tweak this to enable Entity Framework SQL logging
+ if (OptionsAtStartup.Debug && false)
+ {
+ options.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
+ }
});
using var ctx = services