mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-27 12:27:57 +01:00
feat: Enhanced SyncYomi with Robust Locking Mechanism
- Introduced `LockFile` data class to manage sync status and ownership. - Enumerated `SyncStatus` to clearly indicate the stage of synchronization: Pending, Syncing, or Success. - Implemented a new `beforeSync` method utilizing `OkHttpClient` for secure HTTP calls to manage the lock file. - Added JSON serialization for lock file management and status updates. - Implemented exponential backoff strategy to handle concurrent sync attempts and reduce race conditions. - Added comprehensive logging for debugging and monitoring sync processes. This update enhances the reliability and concurrency handling of SyncYomi's synchronization process, ensuring users experience seamless and efficient data syncing in a self-hosted environment. Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
@@ -2,6 +2,7 @@ package tachiyomi.domain.sync
|
||||
|
||||
import tachiyomi.core.preference.Preference
|
||||
import tachiyomi.core.preference.PreferenceStore
|
||||
import java.util.UUID
|
||||
|
||||
class SyncPreferences(
|
||||
private val preferenceStore: PreferenceStore,
|
||||
@@ -22,4 +23,18 @@ class SyncPreferences(
|
||||
Preference.appStateKey("google_drive_refresh_token"),
|
||||
"",
|
||||
)
|
||||
|
||||
fun uniqueDeviceID(): String {
|
||||
val uniqueIDPreference = preferenceStore.getString("unique_device_id", "")
|
||||
|
||||
// Retrieve the current value of the preference
|
||||
var uniqueID = uniqueIDPreference.get()
|
||||
if (uniqueID.isBlank()) {
|
||||
uniqueID = UUID.randomUUID().toString()
|
||||
uniqueIDPreference.set(uniqueID)
|
||||
}
|
||||
|
||||
return uniqueID
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user