UploadEventListener - reset bytesTransfered for each file (#145)

This commit is contained in:
Paul Campbell 2019-08-04 20:12:16 +01:00 committed by GitHub
parent f40fe46d84
commit ec221d9f05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 15 deletions

View file

@ -15,9 +15,10 @@ object UploadEventListener {
totalBytesSoFar: Long totalBytesSoFar: Long
) )
def apply(settings: Settings): UploadEvent => Unit =
uploadEvent => {
var bytesTransferred = 0L var bytesTransferred = 0L
uploadEvent match {
def listener(settings: Settings): UploadEvent => Unit = {
case e: RequestEvent => case e: RequestEvent =>
bytesTransferred += e.transferred bytesTransferred += e.transferred
logRequestCycle( logRequestCycle(
@ -28,5 +29,6 @@ object UploadEventListener {
settings.totalBytesSoFar)) settings.totalBytesSoFar))
case _ => () case _ => ()
} }
}
} }

View file

@ -77,8 +77,7 @@ trait Uploader {
listenerSettings => listenerSettings =>
new ProgressListener { new ProgressListener {
override def progressChanged(progressEvent: ProgressEvent): Unit = override def progressChanged(progressEvent: ProgressEvent): Unit =
UploadEventListener.listener(listenerSettings)( UploadEventListener(listenerSettings)(eventHandler(progressEvent))
eventHandler(progressEvent))
private def eventHandler: ProgressEvent => UploadEvent = private def eventHandler: ProgressEvent => UploadEvent =
progressEvent => { progressEvent => {