Catch exceptions in share repository for blob provider IO exceptions.
This commit is contained in:
parent
57a2a32c71
commit
247edce7b0
1 changed files with 21 additions and 11 deletions
|
@ -60,11 +60,16 @@ class ShareRepository(context: Context) {
|
|||
val size = getSize(appContext, uri)
|
||||
val name = getFileName(appContext, uri)
|
||||
|
||||
val blobUri = BlobProvider.getInstance()
|
||||
.forData(stream, size)
|
||||
.withMimeType(mimeType)
|
||||
.withFileName(name)
|
||||
.createForSingleSessionOnDisk(appContext)
|
||||
val blobUri: Uri = try {
|
||||
BlobProvider.getInstance()
|
||||
.forData(stream, size)
|
||||
.withMimeType(mimeType)
|
||||
.withFileName(name)
|
||||
.createForSingleSessionOnDisk(appContext)
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "Failed to get blob uri")
|
||||
return ResolvedShareData.Failure
|
||||
}
|
||||
|
||||
return ResolvedShareData.ExternalUri(
|
||||
uri = blobUri,
|
||||
|
@ -93,16 +98,21 @@ class ShareRepository(context: Context) {
|
|||
appContext.contentResolver.openInputStream(uri)
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "Failed to open: $uri")
|
||||
return@map null
|
||||
} ?: return ResolvedShareData.Failure
|
||||
null
|
||||
} ?: return@map null
|
||||
|
||||
val size = getSize(appContext, uri)
|
||||
val dimens: Pair<Int, Int> = MediaUtil.getDimensions(appContext, mimeType, uri).toKotlinPair()
|
||||
val duration = 0L
|
||||
val blobUri = BlobProvider.getInstance()
|
||||
.forData(stream, size)
|
||||
.withMimeType(mimeType)
|
||||
.createForSingleSessionOnDisk(appContext)
|
||||
val blobUri = try {
|
||||
BlobProvider.getInstance()
|
||||
.forData(stream, size)
|
||||
.withMimeType(mimeType)
|
||||
.createForSingleSessionOnDisk(appContext)
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "Failed create blob uri")
|
||||
return@map null
|
||||
}
|
||||
|
||||
Media(
|
||||
blobUri,
|
||||
|
|
Loading…
Add table
Reference in a new issue