Return a failure message if the file cannot be opened.

This commit is contained in:
onurays 2020-03-25 18:03:20 +03:00
parent f68e98b2c7
commit 5cb47dae35

View file

@ -90,7 +90,14 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
var newImageAttributes: NewImageAttributes? = null var newImageAttributes: NewImageAttributes? = null
try { try {
val inputStream = context.contentResolver.openInputStream(attachment.queryUri) ?: return Result.success() val inputStream = context.contentResolver.openInputStream(attachment.queryUri)
?: return Result.success(
WorkerParamsFactory.toData(
params.copy(
lastFailureMessage = "Cannot openInputStream for file: " + attachment.queryUri.toString()
)
)
)
inputStream.use { inputStream.use {
var uploadedThumbnailUrl: String? = null var uploadedThumbnailUrl: String? = null
@ -122,8 +129,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
uploadedThumbnailUrl = contentUploadResponse.contentUri uploadedThumbnailUrl = contentUploadResponse.contentUri
} catch (t: Throwable) { } catch (t: Throwable) {
Timber.e(t) Timber.e(t, "Thumbnail update failed")
return handleFailure(params, t)
} }
} }