Skip to content

Commit dfd9bbd

Browse files
committed
fix: stream handling and double-close in UploadFileFromContentUriWorker
1 parent 44a9902 commit dfd9bbd

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

owncloudApp/src/main/java/com/owncloud/android/workers/UploadFileFromContentUriWorker.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,11 @@ class UploadFileFromContentUriWorker(
184184
}
185185
cacheFile.createNewFile()
186186

187-
val inputStream = appContext.contentResolver.openInputStream(contentUri)
188-
val outputStream = FileOutputStream(cachePath)
189-
outputStream.use { fileOut ->
190-
inputStream?.copyTo(fileOut)
187+
appContext.contentResolver.openInputStream(contentUri)?.use { inputStream ->
188+
FileOutputStream(cachePath).use { outputStream ->
189+
inputStream.copyTo(outputStream)
190+
}
191191
}
192-
inputStream?.close()
193-
outputStream.close()
194192

195193
transferRepository.updateTransferSourcePath(uploadIdInStorageManager, contentUri.toString())
196194
transferRepository.updateTransferLocalPath(uploadIdInStorageManager, cachePath)

0 commit comments

Comments
 (0)