Replaced println with printDebug in clone

This commit is contained in:
Abdelilah El Aissaoui 2023-04-15 20:35:03 +02:00
parent e16939a6ef
commit b27af83ae5

View File

@ -1,6 +1,7 @@
package com.jetpackduba.gitnuro.git.remote_operations package com.jetpackduba.gitnuro.git.remote_operations
import com.jetpackduba.gitnuro.git.CloneStatus import com.jetpackduba.gitnuro.git.CloneStatus
import com.jetpackduba.gitnuro.logging.printDebug
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.ensureActive import kotlinx.coroutines.ensureActive
@ -12,6 +13,8 @@ import org.eclipse.jgit.lib.ProgressMonitor
import java.io.File import java.io.File
import javax.inject.Inject import javax.inject.Inject
private const val TAG = "CloneRepositoryUseCase"
class CloneRepositoryUseCase @Inject constructor( class CloneRepositoryUseCase @Inject constructor(
private val handleTransportUseCase: HandleTransportUseCase, private val handleTransportUseCase: HandleTransportUseCase,
) { ) {
@ -30,7 +33,7 @@ class CloneRepositoryUseCase @Inject constructor(
.setProgressMonitor( .setProgressMonitor(
object : ProgressMonitor { object : ProgressMonitor {
override fun start(totalTasks: Int) { override fun start(totalTasks: Int) {
println("ProgressMonitor Start with total tasks of: $totalTasks") printDebug(TAG, "ProgressMonitor Start with total tasks of: $totalTasks")
} }
override fun beginTask(title: String?, totalWork: Int) { override fun beginTask(title: String?, totalWork: Int) {
@ -42,7 +45,7 @@ class CloneRepositoryUseCase @Inject constructor(
} }
override fun update(completed: Int) { override fun update(completed: Int) {
println("ProgressMonitor Update $completed") printDebug(TAG, "ProgressMonitor Update $completed")
ensureActive() ensureActive()
progress += completed progress += completed
@ -50,7 +53,7 @@ class CloneRepositoryUseCase @Inject constructor(
} }
override fun endTask() { override fun endTask() {
println("ProgressMonitor End task") printDebug(TAG, "ProgressMonitor End task")
} }
override fun isCancelled(): Boolean { override fun isCancelled(): Boolean {
@ -68,7 +71,7 @@ class CloneRepositoryUseCase @Inject constructor(
channel.close() channel.close()
} catch (ex: Exception) { } catch (ex: Exception) {
if (ex.cause?.cause is CancellationException) { if (ex.cause?.cause is CancellationException) {
println("Clone cancelled") printDebug(TAG, "Clone cancelled")
} else { } else {
trySend(CloneStatus.Fail(ex.localizedMessage)) trySend(CloneStatus.Fail(ex.localizedMessage))
} }