refactor(database): access the library through EF Core
SongRepository uses Entity Framework Core instead of hand-written SQL. The table and column names stay the same, so existing libraries open unchanged. The duration rule moves into the repository, and a duplicate Openverse id now surfaces as DbUpdateException. Libraries from before the Openverse import, which lack the OpenverseId column, are no longer upgraded. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
7cdc3b3a41
commit
65743279b1
5 files changed
+107
-121
No files matched your search
@@ -232,11 +232,13 @@ public partial class ImportPage : Page
|
||||
_session.Insert(0, SessionRow.Added(song, song.License ?? ""));
|
||||
ReplaceRow(row, row with { Status = "In Bibliothek", CanImport = false });
|
||||
}
|
||||
catch (Exception ex) when (ex is OpenverseException or Microsoft.Data.Sqlite.SqliteException)
|
||||
catch (Exception ex) when (ex is OpenverseException or Microsoft.EntityFrameworkCore.DbUpdateException)
|
||||
{
|
||||
_session.Insert(0, SessionRow.Failed(row.Track.Title, ex.Message));
|
||||
// The database error text is technical and English; the usual cause is a song that is already stored.
|
||||
var reason = ex is OpenverseException ? ex.Message : "Der Song konnte nicht in der Bibliothek gespeichert werden.";
|
||||
_session.Insert(0, SessionRow.Failed(row.Track.Title, reason));
|
||||
failed++;
|
||||
lastError = ex.Message;
|
||||
lastError = reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user