mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
review comments
This commit is contained in:
parent
0d3d9490e5
commit
05e40ecb93
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user