Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: sync category delete and chapters marked as unread. #1154

Closed
wants to merge 3 commits into from

Conversation

kaiserbh
Copy link

@kaiserbh kaiserbh commented Apr 7, 2024

When same device is initiating the sync just update the remote that.

This should fix the issue with chapters being marked as unread or category coming back after it's deleted.

closes: #1149

When same device is initiating the sync just update the remote that.

Signed-off-by: KaiserBh <kaiserbh@proton.me>
@kaiserbh
Copy link
Author

kaiserbh commented Apr 7, 2024

When this is merged can you please ping me @jobobby04 I need to push the release for the syncyomi server.

@Cologler
Copy link

Cologler commented Apr 7, 2024

I have try this to skip unnecessary restore process:

// <-- SyncService.kt
    /**
     * Sync with remote service.
     *
     * - Return syncData itself (reference equal) if nothing changed.
     * - Return null if sync failed.
     */
    open suspend fun doSync(syncData: SyncData): SyncData? {
        beforeSync()

        val remoteSData = pullSyncData()

        val finalSyncData =
            if (remoteSData == null || remoteSData.deviceId == syncData.deviceId) {
                pushSyncData(syncData)
                syncData
            } else {
                val mergedSyncData = mergeSyncData(syncData, remoteSData)
                    .copy(deviceId = syncData.deviceId)
                pushSyncData(mergedSyncData)
                mergedSyncData
            }

        return finalSyncData
    }

// <-- SyncManager.kt
        val syncedData = syncService?.doSync(syncData)

        if (syncedData === syncData) {
            // nothing changed
            updateSyncTimestamp()
            return
        }

        val remoteBackup = syncedData?.backup

When there is network failure or any sort during downloading just throw exception and stop syncing.

Signed-off-by: KaiserBh <kaiserbh@proton.me>
@kaiserbh
Copy link
Author

kaiserbh commented Apr 7, 2024

Currently, if pullSyncData() returns null due to a network error, the pushSyncData() will unexpectedly overwrite the remote data.

Yea true, that was bad design. Updated the new one will throw exception when downloading fails due to network error.

@kaiserbh kaiserbh changed the title fix: same device sync. bugfix: sync category delete and chapters marked as unread. Apr 7, 2024
People with over 3k library can't sync because we are hitting OOM ```java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Failed to allocate a 370950192 byte allocation with 25165824 free bytes and 281MB until OOM, target footprint 333990992, growth limit 603979776```. This should fix that for them but only gdrive.

Signed-off-by: KaiserBh <kaiserbh@proton.me>
@kaiserbh kaiserbh closed this Apr 10, 2024
@kaiserbh
Copy link
Author

Included in #1155

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync feature make the category unable to delete
2 participants