From 5d5a79e06c187cedde3682805d259d50ea0e72c7 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 17 May 2025 15:43:54 -0500 Subject: copy the TransferStates enum into the migration to ensure it remains stable --- .../Migrations/Z04012025_TransferStateMigration.cs | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/slskd/Core/Data/Migrations/Z04012025_TransferStateMigration.cs b/src/slskd/Core/Data/Migrations/Z04012025_TransferStateMigration.cs index f18aba55..bf034d6f 100644 --- a/src/slskd/Core/Data/Migrations/Z04012025_TransferStateMigration.cs +++ b/src/slskd/Core/Data/Migrations/Z04012025_TransferStateMigration.cs @@ -24,7 +24,6 @@ using System.IO; using System.Linq; using Microsoft.Data.Sqlite; using Serilog; -using Soulseek; /// /// Updates the Transfers table to: @@ -83,7 +82,7 @@ public class Z04012025_TransferStateMigration : IMigration while (reader.Read()) { var state = reader.GetString(0); - dict[state] = (int)Enum.Parse(typeof(TransferStates), state); + dict[state] = (int)Enum.Parse(typeof(Z04012025_TransferStateMigration_TransferStates), state); } Log.Debug("State -> int map: {Map}", dict); @@ -205,4 +204,29 @@ public class Z04012025_TransferStateMigration : IMigration throw; } } + +#pragma warning disable SA1201 // Elements should appear in the correct order + /// + /// This is a copy of the TransferStates enum as it was at the time this migration was written. This exists to ensure + /// that the migration can be applied to any version of the database, even if the enum changes in the future. + /// + [Flags] + private enum Z04012025_TransferStateMigration_TransferStates + { + None = 0, + Requested = 1, + Queued = 2, + Initializing = 4, + InProgress = 8, + Completed = 16, + Succeeded = 32, + Cancelled = 64, + TimedOut = 128, + Errored = 256, + Rejected = 512, + Aborted = 1024, + Locally = 2048, + Remotely = 4096, + } +#pragma warning restore SA1201 // Elements should appear in the correct order } -- cgit v1.2.3