Skip to content

Commit

Permalink
Extra logging for SyncProgressHandler
Browse files Browse the repository at this point in the history
Upping gradle wrapper version
  • Loading branch information
Dima-Android committed Jun 24, 2024
1 parent 99bf4c5 commit 249df62
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.zotero.android.architecture.navigation.toolbar.data
import org.zotero.android.sync.LibraryIdentifier
import org.zotero.android.sync.SyncError
import org.zotero.android.sync.SyncObject
import timber.log.Timber
import java.lang.Integer.min
import javax.inject.Inject
import javax.inject.Singleton
Expand All @@ -21,30 +22,39 @@ class SyncProgressHandler @Inject constructor(
}

fun reportNewSync() {
Timber.d("SyncProgressHandler: reportNewSync")
cleanup()
logCurrentProgress()
emitState(SyncProgress.starting)
}

fun reportGroupsSync() {
Timber.d("SyncProgressHandler: reportGroupsSync")
emitState(SyncProgress.groups(null))
}

fun reportGroupCount(count: Int) {
Timber.d("SyncProgressHandler: reportGroupCount $count")
this.currentTotal = count
this.currentDone = 0
logCurrentProgress()
reportGroupProgress()
}

fun reportGroupSynced() {
Timber.d("SyncProgressHandler: reportGroupSynced")
addDone(1)
logCurrentProgress()
reportGroupProgress()
}
fun reportLibrarySync(libraryId: LibraryIdentifier) {
Timber.d("SyncProgressHandler: reportLibrarySync")
val name = this.libraryNames?.get(libraryId) ?: return
emitState(SyncProgress.library(name))
}

fun reportObjectSync(objectS: SyncObject, libraryId: LibraryIdentifier) {
Timber.d("SyncProgressHandler: reportObjectSync")
val name = this.libraryNames?.get(libraryId) ?: return
emitState(
SyncProgress.objectS(
Expand All @@ -57,14 +67,18 @@ class SyncProgressHandler @Inject constructor(
}

fun reportDownloadCount(objectS: SyncObject, count: Int, libraryId: LibraryIdentifier) {
Timber.d("SyncProgressHandler: reportDownloadCount $count")
this.currentTotal = count
this.currentDone = 0
logCurrentProgress()
this.reportDownloadObjectProgress(objectS, libraryId = libraryId)
}

fun reportWrite(count: Int) {
Timber.d("SyncProgressHandler: reportWrite $count")
this.currentDone = 0
this.currentTotal = count
logCurrentProgress()
emitState(
SyncProgress.changes(
progress = SyncProgressData(
Expand All @@ -76,12 +90,16 @@ class SyncProgressHandler @Inject constructor(
}

fun reportDownloadBatchSynced(size: Int, objectS: SyncObject, libraryId: LibraryIdentifier) {
Timber.d("SyncProgressHandler: reportDownloadBatchSynced $size")
addDone(size)
logCurrentProgress()
reportDownloadObjectProgress(objectS, libraryId)
}

fun reportWriteBatchSynced(size: Int) {
Timber.d("SyncProgressHandler: reportWriteBatchSynced $size")
addDone(size)
logCurrentProgress()
emitState(
SyncProgress.changes(
progress = SyncProgressData(
Expand All @@ -92,8 +110,10 @@ class SyncProgressHandler @Inject constructor(
)
}
fun reportUpload(count: Int) {
Timber.d("SyncProgressHandler: reportUpload $count")
this.currentTotal = count
this.currentDone = 0
logCurrentProgress()
emitState(
SyncProgress.uploads(
progress = SyncProgressData(
Expand All @@ -105,7 +125,9 @@ class SyncProgressHandler @Inject constructor(
}

fun reportUploaded() {
Timber.d("SyncProgressHandler: reportUploaded")
addDone(1)
logCurrentProgress()
emitState(
SyncProgress.uploads(
progress = SyncProgressData(
Expand All @@ -117,15 +139,18 @@ class SyncProgressHandler @Inject constructor(
}

fun reportDeletions(libraryId: LibraryIdentifier) {
Timber.d("SyncProgressHandler: reportDeletions")
val name = this.libraryNames?.get(libraryId) ?: return
emitState(SyncProgress.deletions(name))
}

fun reportFinish(errors: List<SyncError.NonFatal>) {
Timber.d("SyncProgressHandler: reportFinish errors ${errors.size}")
finish(SyncProgress.finished(errors))
}

fun reportAbort(error: SyncError.Fatal) {
Timber.d("SyncProgressHandler: reportAbort ${error.message}")
finish(SyncProgress.aborted(error))
}

Expand Down Expand Up @@ -162,7 +187,11 @@ class SyncProgressHandler @Inject constructor(
this.libraryNames = null
this.currentDone = 0
this.currentTotal = 0
logCurrentProgress()
}

private fun logCurrentProgress() {
Timber.d("SyncProgressHandler: currentProgress $currentDone/$currentTotal")
}

}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Aug 15 17:35:12 GST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 249df62

Please sign in to comment.