mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
fix downloaded playback and tighten the download state machine
Review findings on the first downloads block: - ExoPlayer could not open a downloaded file at all: the service's data source factory was OkHttp only, so a file:// URI went to the HTTP stack and failed with a malformed URL. Wrap it in DefaultDataSource so the file, asset and content schemes are resolved before the stream chain, and cover it with a test that reads a local file through the production factory. - Reconcile no longer restarts a failed download, or a running one whose engine entry vanished: only a queued row is started again, and the rest become failed so the explicit Retry in the UI means something. - song_downloads also references songs with CASCADE now, so a song pruned from the mirror takes its download row with it and the sweep can reclaim the file. - The mutating methods run on the injected dispatcher rather than the caller's, which was the main thread for every call site, and the repository exposes one shared state flow instead of a second map plus five subscriptions. - Playback stops when the active source disappears, including deleting the last source while a downloaded track is playing. - Dropped the unused request mime type, the queued-at column nothing read, the metered constructor parameter nobody varied, and a dead index guard. - The running indicator is asserted positively, the engine's status and reason mapping has a test, and the failure paths use the fake's failure and forget helpers.
This commit is contained in:
+16
-10
@@ -2,7 +2,7 @@
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 18,
|
||||
"identityHash": "5af02d01d5774106a81b2d031b6bd215",
|
||||
"identityHash": "982f1044d9532868990a4e14017ad3d1",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "sources",
|
||||
@@ -1105,7 +1105,7 @@
|
||||
},
|
||||
{
|
||||
"tableName": "song_downloads",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceId` INTEGER NOT NULL, `songId` TEXT NOT NULL, `status` TEXT NOT NULL, `engineId` INTEGER, `bytes` INTEGER NOT NULL DEFAULT 0, `total` INTEGER NOT NULL DEFAULT 0, `error` TEXT, `queuedAt` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`sourceId`, `songId`), FOREIGN KEY(`sourceId`) REFERENCES `sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceId` INTEGER NOT NULL, `songId` TEXT NOT NULL, `status` TEXT NOT NULL, `engineId` INTEGER, `bytes` INTEGER NOT NULL DEFAULT 0, `total` INTEGER NOT NULL DEFAULT 0, `error` TEXT, PRIMARY KEY(`sourceId`, `songId`), FOREIGN KEY(`sourceId`) REFERENCES `sources`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`sourceId`, `songId`) REFERENCES `songs`(`sourceId`, `id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "sourceId",
|
||||
@@ -1148,13 +1148,6 @@
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT"
|
||||
},
|
||||
{
|
||||
"fieldPath": "queuedAt",
|
||||
"columnName": "queuedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
@@ -1195,13 +1188,26 @@
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table": "songs",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"sourceId",
|
||||
"songId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"sourceId",
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5af02d01d5774106a81b2d031b6bd215')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '982f1044d9532868990a4e14017ad3d1')"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user