Skip to content

Commit

Permalink
Even more logging to troubleshoot errors
Browse files Browse the repository at this point in the history
  • Loading branch information
savvasdalkitsis committed Dec 13, 2024
1 parent 33a3a8e commit 0bccd78
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.savvasdalkitsis.uhuruphotos.feature.upload.domain.api.model.UploadIte
import com.savvasdalkitsis.uhuruphotos.feature.upload.domain.api.usecase.UploadUseCase
import com.savvasdalkitsis.uhuruphotos.feature.uploads.domain.api.usecase.UploadsUseCase
import com.savvasdalkitsis.uhuruphotos.foundation.initializer.api.ApplicationCreated
import com.savvasdalkitsis.uhuruphotos.foundation.log.api.log
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
Expand Down Expand Up @@ -54,7 +53,6 @@ class SyncInitializer @Inject constructor(
) { pending, networkRequirement, requiresCharging ->
Triple(pending, networkRequirement, requiresCharging)
}.collectLatest { (pending, networkRequirement, requiresCharging) ->
log { "Will schedule upload of ${pending.map { it.contentUri }} items" }
uploadUseCase.scheduleUpload(
networkType = networkRequirement,
requiresCharging = requiresCharging,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.savvasdalkitsis.uhuruphotos.feature.media.remote.domain.api.model.Rem
import com.savvasdalkitsis.uhuruphotos.feature.media.remote.domain.api.model.RemoteMediaItemSummaryStatus.Processing
import com.savvasdalkitsis.uhuruphotos.feature.media.remote.domain.api.usecase.RemoteMediaUseCase
import com.savvasdalkitsis.uhuruphotos.feature.upload.domain.api.usecase.UploadUseCase
import com.savvasdalkitsis.uhuruphotos.foundation.log.api.log
import com.savvasdalkitsis.uhuruphotos.foundation.notification.api.ForegroundInfoBuilder
import com.savvasdalkitsis.uhuruphotos.foundation.notification.api.ForegroundNotificationWorker
import com.savvasdalkitsis.uhuruphotos.foundation.strings.api.R.string
Expand Down Expand Up @@ -54,6 +55,7 @@ class UploadPostCompletionWorker @AssistedInject constructor(

override suspend fun work(): Result = coroutineBinding {
val hash = params.inputData.getString(KEY_HASH)!!
log { "Post completion of item $hash" }
when (val status = mediaUseCase.getRemoteMediaItemSummary(hash).bind()) {
is Found -> {
feedUseCase.refreshCluster(status.containerId).bind()
Expand All @@ -64,6 +66,8 @@ class UploadPostCompletionWorker @AssistedInject constructor(
uploadUseCase.saveLastResponseForProcessingItem(itemId, status.response.toString())
failOrRetry(itemId)
}
}.also {
log { "Result of post completion for $hash was $it" }
}
}.onFailure {
uploadUseCase.saveErrorForProcessingItem(itemId, it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.work.WorkInfo
import com.savvasdalkitsis.uhuruphotos.feature.media.common.domain.api.model.MediaItemHashModel
import com.savvasdalkitsis.uhuruphotos.feature.upload.domain.api.model.UploadItem
import com.savvasdalkitsis.uhuruphotos.feature.upload.domain.api.work.UploadWorkScheduler
import com.savvasdalkitsis.uhuruphotos.foundation.log.api.log
import com.savvasdalkitsis.uhuruphotos.foundation.worker.api.usecase.WorkScheduleUseCase
import com.savvasdalkitsis.uhuruphotos.foundation.worker.api.usecase.WorkerStatusUseCase
import kotlinx.coroutines.flow.Flow
Expand All @@ -40,6 +41,7 @@ class UploadWorkScheduler @Inject constructor(
networkType: NetworkType,
requiresCharging: Boolean,
) = with(UploadWorker) {
log { "Will schedule upload of $item" }
workScheduleUseCase.scheduleNow(
workName = workName(item.id),
klass = UploadWorker::class,
Expand All @@ -58,6 +60,7 @@ class UploadWorkScheduler @Inject constructor(
hash: MediaItemHashModel,
itemId: Long,
) = with(UploadPostCompletionWorker) {
log { "Will schedule post completion of $hash" }
workScheduleUseCase.scheduleNow(
workName = workName(hash.hash),
klass = UploadPostCompletionWorker::class,
Expand Down

0 comments on commit 0bccd78

Please sign in to comment.