mirror of https://github.com/jellyfin/jellyfin.git
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)
|
public static int SelectScalarInt(this SqliteCommand command)
|
||||||
{
|
{
|
||||||
var result = command.ExecuteScalar();
|
var result = command.ExecuteScalar();
|
||||||
|
// Can't be null since the method is used to retrieve Count
|
||||||
return Convert.ToInt32(result!, CultureInfo.InvariantCulture);
|
return Convert.ToInt32(result!, CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@ namespace Jellyfin.Server.Migrations.Routines
|
||||||
var dataPath = _paths.DataPath;
|
var dataPath = _paths.DataPath;
|
||||||
var dbPath = Path.Combine(dataPath, DbFilename);
|
var dbPath = Path.Combine(dataPath, DbFilename);
|
||||||
using (var connection = new SqliteConnection($"Filename={dbPath}"))
|
using (var connection = new SqliteConnection($"Filename={dbPath}"))
|
||||||
|
using (var transaction = connection.BeginTransaction())
|
||||||
{
|
{
|
||||||
// Query the database for the ids of duplicate extras
|
// 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'");
|
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)));
|
||||||
var bads = string.Join(", ", queryResult.Select(x => x.GetString(0)).ToList());
|
|
||||||
|
|
||||||
// Do nothing if no duplicate extras were detected
|
// Do nothing if no duplicate extras were detected
|
||||||
if (bads.Length == 0)
|
if (bads.Length == 0)
|
||||||
|
@ -75,6 +75,7 @@ namespace Jellyfin.Server.Migrations.Routines
|
||||||
// Delete all duplicate extras
|
// Delete all duplicate extras
|
||||||
_logger.LogInformation("Removing found duplicated extras for the following items: {DuplicateExtras}", bads);
|
_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')");
|
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…
Reference in New Issue