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
|
|
@ -90,7 +90,6 @@ class MetadataExtractionWorker(
|
|||
}
|
||||
}
|
||||
|
||||
// Only update if we actually found something useful
|
||||
if (coverPath != null || title != null || author != null) {
|
||||
val updatedItem = item.copy(
|
||||
coverImagePath = coverPath ?: item.coverImagePath,
|
||||
|
|
@ -99,6 +98,13 @@ class MetadataExtractionWorker(
|
|||
)
|
||||
recentFilesRepository.addRecentFile(updatedItem)
|
||||
Timber.tag("MetadataWorker").d("Updated metadata for: ${item.displayName}")
|
||||
|
||||
try {
|
||||
recentFilesRepository.syncLocalMetadataToFolder(updatedItem.bookId)
|
||||
Timber.tag("MetadataWorker").d("Created/Updated JSON for: ${item.displayName}")
|
||||
} catch (_: Exception) {
|
||||
Timber.tag("MetadataWorker").w("Failed to save JSON during extraction for ${item.displayName}")
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue