Skip to content

Commit

Permalink
[LEIP-222] Fix upload progress
Browse files Browse the repository at this point in the history
  • Loading branch information
hb0 committed Mar 27, 2024
1 parent 3c48480 commit d8e7594
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ class WebdavUploader(
progressListener: UploadProgressListener
): Result {
val endpoint = URL(measurementDirectory(metaData.measurementIdentifier.toLong()))
return uploadFile(metaData, file, MEASUREMENT_FILE_FILENAME, endpoint)
val result = uploadFile(metaData, file, MEASUREMENT_FILE_FILENAME, endpoint, progressListener)
if (result != Result.UPLOAD_FAILED) {
progressListener.updatedProgress(1.0f) // the whole file is uploaded
}
return result
}

override fun uploadAttachment(
Expand All @@ -99,7 +103,11 @@ class WebdavUploader(
progressListener: UploadProgressListener
): Result {
val endpoint = attachmentsEndpoint(measurementId)
return uploadFile(metaData, file, fileName, endpoint)
val result = uploadFile(metaData, file, fileName, endpoint, progressListener)
if (result != Result.UPLOAD_FAILED) {
progressListener.updatedProgress(1.0f) // the whole file is uploaded
}
return result
}

override fun measurementsEndpoint(): URL {
Expand Down Expand Up @@ -136,7 +144,8 @@ class WebdavUploader(
metaData: RequestMetaData,
file: File,
fileName: String,
endpoint: URL
endpoint: URL,
progressListener: UploadProgressListener
): Result {
return try {
// TODO: the sardine library has PRs which support input streams but they are not merged
Expand Down

0 comments on commit d8e7594

Please sign in to comment.