mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 21:19:31 +01:00
catch FileNotFoundException in copyFileToCache
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
976ca95959
commit
27bbb399be
@ -53,6 +53,7 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|||||||
import okhttp3.RequestBody
|
import okhttp3.RequestBody
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileNotFoundException
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
@ -167,12 +168,15 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||||||
Log.d(TAG, "file is already in cache")
|
Log.d(TAG, "file is already in cache")
|
||||||
} else {
|
} else {
|
||||||
val outputStream = FileOutputStream(cachedFile)
|
val outputStream = FileOutputStream(cachedFile)
|
||||||
val inputStream: InputStream = context.contentResolver.openInputStream(sourceFileUri)!!
|
try {
|
||||||
|
val inputStream: InputStream? = context.contentResolver.openInputStream(sourceFileUri)
|
||||||
inputStream.use { input ->
|
inputStream?.use { input ->
|
||||||
outputStream.use { output ->
|
outputStream.use { output ->
|
||||||
input.copyTo(output)
|
input.copyTo(output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: FileNotFoundException) {
|
||||||
|
Log.w(TAG, "failed to copy file to cache", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user