Remove unnecessary migration, autoformat

This commit is contained in:
Nicholas Wallace
2026-07-20 19:06:35 -07:00
parent dc6184f41d
commit 245df5d934
@@ -7,7 +7,6 @@ import com.audiobookshelf.app.models.DownloadItem
import com.audiobookshelf.app.plugins.AbsLog import com.audiobookshelf.app.plugins.AbsLog
import com.audiobookshelf.app.plugins.AbsLogger import com.audiobookshelf.app.plugins.AbsLogger
import io.paperdb.Paper import io.paperdb.Paper
import java.io.File
class DbManager { class DbManager {
val tag = "DbManager" val tag = "DbManager"
@@ -122,21 +121,6 @@ class DbManager {
return downloadItems return downloadItems
} }
/**
* Removes DownloadManager queue entries that cannot be resumed by the app-managed downloader.
*
* This migration preserves completed local media, which is stored in separate books.
*/
fun clearLegacyDownloadQueueOnce() {
val metadata = Paper.book("downloadQueueMetadata")
val architectureVersion = metadata.read<Int>("architectureVersion") ?: 0
if (architectureVersion >= 2) return
Paper.book("downloadItems").destroy()
metadata.write("architectureVersion", 2)
Log.i(tag, "Cleared legacy persisted download queue for architecture v2")
}
fun saveLocalMediaProgress(mediaProgress: LocalMediaProgress) { fun saveLocalMediaProgress(mediaProgress: LocalMediaProgress) {
Paper.book("localMediaProgress").write(mediaProgress.id, mediaProgress) Paper.book("localMediaProgress").write(mediaProgress.id, mediaProgress)
} }
@@ -218,9 +202,10 @@ class DbManager {
// Check cover still there // Check cover still there
lli.coverAbsolutePath?.let { lli.coverAbsolutePath?.let {
val coverExists = lli.localFiles.any { localFile -> val coverExists =
localFile.absolutePath == it && localFile.exists(context) lli.localFiles.any { localFile ->
} localFile.absolutePath == it && localFile.exists(context)
}
if (!coverExists) { if (!coverExists) {
Log.d( Log.d(
tag, tag,
@@ -306,15 +291,13 @@ class DbManager {
return sessions return sessions
} }
fun saveLog(log:AbsLog) { fun saveLog(log: AbsLog) {
Paper.book("log").write(log.id, log) Paper.book("log").write(log.id, log)
} }
fun getAllLogs() : List<AbsLog> { fun getAllLogs(): List<AbsLog> {
val logs:MutableList<AbsLog> = mutableListOf() val logs: MutableList<AbsLog> = mutableListOf()
Paper.book("log").allKeys.forEach { logId -> Paper.book("log").allKeys.forEach { logId ->
Paper.book("log").read<AbsLog>(logId)?.let { Paper.book("log").read<AbsLog>(logId)?.let { logs.add(it) }
logs.add(it)
}
} }
return logs.sortedBy { it.timestamp } return logs.sortedBy { it.timestamp }
} }
@@ -333,7 +316,10 @@ class DbManager {
} }
} }
if (logsRemoved > 0) { if (logsRemoved > 0) {
AbsLogger.info("DbManager", "cleanLogs: Removed $logsRemoved logs older than $numberOfHoursToKeep hours") AbsLogger.info(
"DbManager",
"cleanLogs: Removed $logsRemoved logs older than $numberOfHoursToKeep hours"
)
} }
} }
} }