aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvium <clausvium@gmail.com>2023-08-22 08:31:34 +0200
committercvium <clausvium@gmail.com>2023-08-22 08:31:34 +0200
commit05e40ecb933f1b8734e026dd3cefe9e05122b712 (patch)
tree38dfd5ebb6f56ca6400ed81f57c3855c9c484574
parent0d3d9490e5997824cfd97c6776ca000be127deef (diff)
review comments
-rw-r--r--Emby.Server.Implementations/Data/SqliteExtensions.cs1
-rw-r--r--Jellyfin.Server/Migrations/Routines/RemoveDuplicateExtras.cs5
2 files changed, 4 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs
index f3b3da64f..30e334393 100644
--- a/Emby.Server.Implementations/Data/SqliteExtensions.cs
+++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs
@@ -243,6 +243,7 @@ namespace Emby.Server.Implementations.Data
public static int SelectScalarInt(this SqliteCommand command)
{
var result = command.ExecuteScalar();
+ // Can't be null since the method is used to retrieve Count
return Convert.ToInt32(result!, CultureInfo.InvariantCulture);
}
diff --git a/Jellyfin.Server/Migrations/Routines/RemoveDuplicateExtras.cs b/Jellyfin.Server/Migrations/Routines/RemoveDuplicateExtras.cs
index 98017e3ef..6c34e1f5b 100644
--- a/Jellyfin.Server/Migrations/Routines/RemoveDuplicateExtras.cs
+++ b/Jellyfin.Server/Migrations/Routines/RemoveDuplicateExtras.cs
@@ -39,11 +39,11 @@ namespace Jellyfin.Server.Migrations.Routines
var dataPath = _paths.DataPath;
var dbPath = Path.Combine(dataPath, DbFilename);
using (var connection = new SqliteConnection($"Filename={dbPath}"))
+ using (var transaction = connection.BeginTransaction())
{
// Query the database for the ids of duplicate extras
var queryResult = connection.Query("SELECT t1.Path FROM TypedBaseItems AS t1, TypedBaseItems AS t2 WHERE t1.Path=t2.Path AND t1.Type!=t2.Type AND t1.Type='MediaBrowser.Controller.Entities.Video'");
- // TODO does this LINQ execute before the reader is disposed?
- var bads = string.Join(", ", queryResult.Select(x => x.GetString(0)).ToList());
+ var bads = string.Join(", ", queryResult.Select(x => x.GetString(0)));
// Do nothing if no duplicate extras were detected
if (bads.Length == 0)
@@ -75,6 +75,7 @@ namespace Jellyfin.Server.Migrations.Routines
// Delete all duplicate extras
_logger.LogInformation("Removing found duplicated extras for the following items: {DuplicateExtras}", bads);
connection.Execute("DELETE FROM TypedBaseItems WHERE rowid IN (SELECT t1.rowid FROM TypedBaseItems AS t1, TypedBaseItems AS t2 WHERE t1.Path=t2.Path AND t1.Type!=t2.Type AND t1.Type='MediaBrowser.Controller.Entities.Video')");
+ transaction.Commit();
}
}
}