Expanded folder sync functionality to support multiple folders and improved performance. (#47)
- Added `SyncedFolder` data class and transitioned from a single `syncedFolderUri` to a list of `syncedFolders`. - Implemented logic to add, remove, and persist multiple synced folders using JSON in shared preferences, including a migration path for legacy single-folder settings. - Updated `FolderSyncWorker` to iterate through all registered folders and added an annotation sidecar preloading optimization to reduce file I/O during sync. - Redesigned the "Folder Sync" UI in `LibraryScreen` to display a list of active folders with individual management options and a 3-folder limit. - Refined permission handling to request both read and write access for synced folders.
This commit is contained in:
parent
76780bff31
commit
6ea414c9b2
6 changed files with 426 additions and 298 deletions
|
|
@ -29,8 +29,12 @@ class MetadataExtractionWorker(
|
|||
|
||||
override suspend fun doWork(): Result = withContext(Dispatchers.IO) {
|
||||
val prefs = appContext.getSharedPreferences("reader_user_prefs", Context.MODE_PRIVATE)
|
||||
if (!prefs.contains(MainViewModel.KEY_SYNCED_FOLDER_URI)) {
|
||||
Timber.tag("MetadataWorker").w("Folder disconnected. Stopping extraction worker.")
|
||||
|
||||
val hasLegacy = prefs.contains("synced_folder_uri")
|
||||
val hasNew = prefs.contains("synced_folders_list_json")
|
||||
|
||||
if (!hasLegacy && !hasNew) {
|
||||
Timber.tag("MetadataWorker").w("No folders linked. Stopping.")
|
||||
return@withContext Result.success()
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +50,7 @@ class MetadataExtractionWorker(
|
|||
filesToProcess.forEach { item ->
|
||||
if (isStopped) return@forEach
|
||||
|
||||
if (!prefs.contains(MainViewModel.KEY_SYNCED_FOLDER_URI)) return@forEach
|
||||
if (item.sourceFolderUri == null) return@forEach
|
||||
|
||||
try {
|
||||
val uri = item.uriString?.toUri() ?: return@forEach
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue