aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-04-30 23:43:50 -0500
committerJP Dillingham <jp@dillingham.me>2026-04-30 23:43:50 -0500
commit3abaadcd87383c22bc380d6c2fd9b05e38e7d353 (patch)
tree76a4100e45fdf82464c5e58b9c5e94d0e73a4bbe /src
parentff430b438a6498c1f26e318d6d850de41a3634b4 (diff)
downloadslskd-3abaadcd87383c22bc380d6c2fd9b05e38e7d353.tar.gz
remove StartOffset from Transfers table (unused)
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Data/Migrations/Z2026_04_30_DropTransferStartOffsetMigration.cs101
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs1
-rw-r--r--src/slskd/Transfers/Types/Transfer.cs2
-rw-r--r--src/slskd/Transfers/Uploads/UploadService.cs1
4 files changed, 102 insertions, 3 deletions
diff --git a/src/slskd/Core/Data/Migrations/Z2026_04_30_DropTransferStartOffsetMigration.cs b/src/slskd/Core/Data/Migrations/Z2026_04_30_DropTransferStartOffsetMigration.cs
new file mode 100644
index 00000000..4fb25b1f
--- /dev/null
+++ b/src/slskd/Core/Data/Migrations/Z2026_04_30_DropTransferStartOffsetMigration.cs
@@ -0,0 +1,101 @@
+// <copyright file="Z2026_04_30_DropTransferStartOffsetMigration.cs" company="JP Dillingham">
+// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄
+// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █
+// █__ --█ █__ --█ ◄█ - █
+// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█
+// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉
+// │ Copyright (c) JP Dillingham.
+// │
+// │ 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, version 3.
+// │
+// │ 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/.
+// │
+// │ This program is distributed with Additional Terms pursuant to Section 7
+// │ of the AGPLv3. See the LICENSE file in the root directory of this
+// │ project for the complete terms and conditions.
+// │
+// │ https://slskd.org
+// │
+// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌
+// │ SPDX-FileCopyrightText: JP Dillingham
+// │ SPDX-License-Identifier: AGPL-3.0-only
+// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈
+// </copyright>
+
+namespace slskd.Migrations;
+
+using System;
+using System.Linq;
+using Microsoft.Data.Sqlite;
+using Serilog;
+
+/// <summary>
+/// Updates the Transfers table to drop the unused StartOffset column.
+/// </summary>
+public class Z2026_04_30_DropTransferStartOffsetMigration : IMigration
+{
+ public Z2026_04_30_DropTransferStartOffsetMigration(ConnectionStringDictionary connectionStrings)
+ {
+ ConnectionString = connectionStrings[Database.Transfers];
+ }
+
+ private ILogger Log { get; } = Serilog.Log.ForContext<Z2026_04_30_DropTransferStartOffsetMigration>();
+ private string ConnectionString { get; }
+
+ public bool NeedsToBeApplied()
+ {
+ var schema = SchemaInspector.GetDatabaseSchema(ConnectionString);
+
+ var columns = schema["Transfers"];
+
+ if (columns.Any(c => c.Name == "StartOffset"))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ public void Apply()
+ {
+ if (!NeedsToBeApplied())
+ {
+ Log.Information("> Migration {Name} is not necessary or has already been applied", nameof(Z2026_04_30_DropTransferStartOffsetMigration));
+ return;
+ }
+
+ using var connection = new SqliteConnection(ConnectionString);
+ connection.Open();
+
+ using var transaction = connection.BeginTransaction();
+
+ try
+ {
+ void Exec(string sql)
+ {
+ using var command = new SqliteCommand(sql, connection, transaction);
+ command.ExecuteNonQuery();
+ }
+
+ Log.Information("> Dropping StartOffset column from the Transfers table...");
+
+ Exec("ALTER TABLE Transfers DROP COLUMN StartOffset;");
+
+ transaction.Commit();
+ Log.Information("> Done!");
+ }
+ catch (Exception)
+ {
+ transaction.Rollback();
+ throw;
+ }
+ }
+}
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index 0ccf52c3..aba6ca9d 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -435,7 +435,6 @@ namespace slskd.Transfers.Downloads
Direction = TransferDirection.Download,
Filename = file.Filename, // important! use the remote filename
Size = file.Size,
- StartOffset = 0, // todo: maybe implement resumeable downloads?
RequestedAt = DateTime.UtcNow,
State = TransferStates.Queued | TransferStates.Locally,
};
diff --git a/src/slskd/Transfers/Types/Transfer.cs b/src/slskd/Transfers/Types/Transfer.cs
index 93a23380..90fbe612 100644
--- a/src/slskd/Transfers/Types/Transfer.cs
+++ b/src/slskd/Transfers/Types/Transfer.cs
@@ -30,7 +30,7 @@
// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈
// </copyright>
-namespace slskd.Transfers
+namespace slskd.Transfers;
{
using System;
using System.ComponentModel.DataAnnotations;
diff --git a/src/slskd/Transfers/Uploads/UploadService.cs b/src/slskd/Transfers/Uploads/UploadService.cs
index 13915e82..9bb09f66 100644
--- a/src/slskd/Transfers/Uploads/UploadService.cs
+++ b/src/slskd/Transfers/Uploads/UploadService.cs
@@ -622,7 +622,6 @@ namespace slskd.Transfers.Uploads
Direction = TransferDirection.Upload,
Filename = filename, // important! use the remote filename
Size = localFileLength,
- StartOffset = 0, // potentially updated later during handshaking
RequestedAt = DateTime.UtcNow,
State = TransferStates.Queued | TransferStates.Locally,
};