many improvements and prototype launcher image
This commit is contained in:
1 parent
11c8f7c6e4
commit
6422f814d1
27 files changed
+530
-232
No files matched your search
@@ -217,6 +217,8 @@ interface ReadingStateRepository {
|
||||
fun upsert(state: ReadingStateRecord)
|
||||
fun get(id: String): ReadingStateRecord?
|
||||
fun getForBodyCluster(bodyClusterId: String): ReadingStateRecord?
|
||||
fun deleteForBodyCluster(bodyClusterId: String): Int
|
||||
fun delete(id: String): Boolean
|
||||
}
|
||||
|
||||
interface BookmarkRepository {
|
||||
|
||||
@@ -862,6 +862,15 @@ private class JdbcReadingStateRepository(private val connection: Connection) : R
|
||||
it.toReadingStateRecord()
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteForBodyCluster(bodyClusterId: String): Int {
|
||||
return connection.prepareStatement("DELETE FROM reading_states WHERE body_cluster_id = ?").use { statement ->
|
||||
statement.setString(1, bodyClusterId)
|
||||
statement.executeUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
override fun delete(id: String): Boolean = connection.deleteById("reading_states", id)
|
||||
}
|
||||
|
||||
private class JdbcBookmarkRepository(private val connection: Connection) : BookmarkRepository {
|
||||
|
||||
@@ -376,6 +376,42 @@ class H2LibraryDatabaseTest {
|
||||
H2LibraryDatabase.openFile(path).close()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun persistsReadingStatusAcrossDatabaseRestart() {
|
||||
val path = Files.createTempDirectory("toread-h2-reading-status-").resolve("library").toString()
|
||||
val now = 1_700_000_000_000L
|
||||
|
||||
val initialDb = H2LibraryDatabase.openFile(path)
|
||||
try {
|
||||
val db = initialDb
|
||||
db.transaction {
|
||||
books.upsert(BookRecord(id = "book-1", title = "Persistent", createdAt = now, updatedAt = now))
|
||||
files.upsert(
|
||||
BookFileRecord(
|
||||
id = "file-1",
|
||||
bookId = "book-1",
|
||||
rawSha256 = "sha-1",
|
||||
storageKind = BookFileStorageKind.EXTERNAL_URI,
|
||||
createdAt = now,
|
||||
updatedAt = now,
|
||||
)
|
||||
)
|
||||
}
|
||||
assertEquals(true, db.files.updateReadingStatus("file-1", BookReadingStatus.NOT_INTERESTED))
|
||||
} finally {
|
||||
initialDb.close()
|
||||
}
|
||||
|
||||
val reopenedDb = H2LibraryDatabase.openFile(path)
|
||||
try {
|
||||
val db = reopenedDb
|
||||
assertEquals(BookReadingStatus.NOT_INTERESTED, db.files.get("file-1")?.readingStatus)
|
||||
assertEquals(BookReadingStatus.NOT_INTERESTED, db.files.getLibraryFile("file-1")?.readingStatus)
|
||||
} finally {
|
||||
reopenedDb.close()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migratesLegacyBookFilesWithImportTime() {
|
||||
val path = Files.createTempDirectory("toread-h2-imported-at-").resolve("library").toString()
|
||||
|
||||
Reference in new issue
Block a user