Skip to content

Commit

Permalink
properly closing response bodies when done with them
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbluesky committed Jan 28, 2024
1 parent 68db12d commit a5f48c0
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class PixivArtWorker(context: Context, workerParams: WorkerParameters) :

// The other method using BufferedSink doesn't work all we have is a URI to sink into
val fis = responseBody!!.byteStream()
responseBody.close()
val fosExternal: OutputStream? = contentResolver.openOutputStream(imageUri)
val buffer = ByteArray(1024 * 1024 * 10)
var lengthInternal: Int
Expand Down Expand Up @@ -453,6 +454,8 @@ class PixivArtWorker(context: Context, workerParams: WorkerParameters) :
if (it.isSuccessful) {
Log.i(LOG_TAG, "Getting remote file extensions completed")
return it.body
} else {
it.close()
}
}
}
Expand Down

0 comments on commit a5f48c0

Please sign in to comment.