Refactored folder synchronization logic and improved migration handling (#21)
- Updated `MainViewModel` to skip synchronization until folder migration is completed and added metadata syncing when opening books. - Modified folder migration to detach existing folder books (converting them to standard local files) before starting a fresh scan. - Added `detachAllFolderBooks` to `RecentFileDao` and `RecentFilesRepository` to facilitate the migration process. - Updated `MetadataExtractionWorker` to sync local metadata to the folder immediately after extraction. - Simplified `FolderSyncWorker` by removing legacy migration lookups and streamlining the reconciliation of local and remote metadata. - Updated `FolderMigrationDialog` UI text to reflect that books are now read directly from folders without duplication. - Fixed various indentation and formatting issues across several files.
This commit is contained in:
parent
34c6ec3fef
commit
0885b6949e
6 changed files with 105 additions and 196 deletions
|
|
@ -87,4 +87,7 @@ interface RecentFileDao {
|
|||
|
||||
@Query("SELECT * FROM recent_files WHERE sourceFolderUri IS NOT NULL AND coverImagePath IS NULL AND isDeleted = 0")
|
||||
suspend fun getFolderBooksWithoutCovers(): List<RecentFileEntity>
|
||||
|
||||
@Query("UPDATE recent_files SET sourceFolderUri = NULL WHERE sourceFolderUri IS NOT NULL")
|
||||
suspend fun detachAllFolderBooks()
|
||||
}
|
||||
|
|
@ -172,6 +172,11 @@ class RecentFilesRepository(private val context: Context) {
|
|||
return@withContext recentFileDao.getFolderBooksWithoutCovers().map { it.toRecentFileItem() }
|
||||
}
|
||||
|
||||
suspend fun detachAllFolderBooks() = withContext(Dispatchers.IO) {
|
||||
recentFileDao.detachAllFolderBooks()
|
||||
Timber.d("Detached all folder books. They are now standard local files.")
|
||||
}
|
||||
|
||||
suspend fun updateBookmarks(bookId: String, bookmarksJson: String) = withContext(Dispatchers.IO) {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
recentFileDao.updateBookmarks(bookId, bookmarksJson, currentTime)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue