Progress UI should be updated when upload fails (#218)
* [uishell] Rename UIRequestCycle as ProgressUI * [uishell] Rename ProgressUI.handle as requestCycle * [uishell] Remove upload from ProgressUI upon error * [uishell] Remove upload from ProgressUI upon completion
This commit is contained in:
parent
7b567ab28c
commit
22d2cf4a57
2 changed files with 15 additions and 12 deletions
|
@ -11,7 +11,7 @@ import zio.{UIO, ZIO}
|
|||
|
||||
import scala.io.AnsiColor.{GREEN, RESET}
|
||||
|
||||
object UIRequestCycle {
|
||||
object ProgressUI {
|
||||
|
||||
private case class UploadState(transferred: Long, fileLength: Long)
|
||||
|
||||
|
@ -20,7 +20,8 @@ object UIRequestCycle {
|
|||
|
||||
private val statusHeight = 3
|
||||
|
||||
def handle(localFile: LocalFile,
|
||||
def requestCycle(
|
||||
localFile: LocalFile,
|
||||
bytesTransferred: Long,
|
||||
index: Int,
|
||||
totalBytesSoFar: Long): ZIO[Console with Config, Nothing, Unit] =
|
||||
|
@ -62,7 +63,7 @@ object UIRequestCycle {
|
|||
} *> Console.putStr(resetCursor)
|
||||
}
|
||||
|
||||
private def finishedUploading(
|
||||
def finishedUploading(
|
||||
remoteKey: RemoteKey
|
||||
): ZIO[Any, Nothing, Unit] = {
|
||||
UIO(uploads.updateAndGet((m: Map[RemoteKey, UploadState]) =>
|
|
@ -35,7 +35,7 @@ object UIShell {
|
|||
bytesTransferred,
|
||||
index,
|
||||
totalBytesSoFar) =>
|
||||
UIRequestCycle.handle(localFile,
|
||||
ProgressUI.requestCycle(localFile,
|
||||
bytesTransferred,
|
||||
index,
|
||||
totalBytesSoFar)
|
||||
|
@ -51,10 +51,12 @@ object UIShell {
|
|||
case StorageEvent.CopyEvent(sourceKey, targetKey) =>
|
||||
Console.putMessageLnB(CopyComplete(sourceKey, targetKey), batchMode)
|
||||
case StorageEvent.UploadEvent(remoteKey, md5Hash) =>
|
||||
ProgressUI.finishedUploading(remoteKey) *>
|
||||
Console.putMessageLnB(UploadComplete(remoteKey), batchMode)
|
||||
case StorageEvent.DeleteEvent(remoteKey) =>
|
||||
Console.putMessageLnB(DeleteComplete(remoteKey), batchMode)
|
||||
case StorageEvent.ErrorEvent(action, remoteKey, e) =>
|
||||
ProgressUI.finishedUploading(remoteKey) *>
|
||||
Console.putMessageLnB(ErrorQueueEventOccurred(action, e), batchMode)
|
||||
case StorageEvent.ShutdownEvent() => UIO.unit
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue