Close open FD after file export to avoid resource leaks

This commit is contained in:
Matéo Duparc 2024-11-11 17:24:35 +01:00
parent 88bd746359
commit b477272d65
Signed by: hardcoresushi
GPG Key ID: AFE384344A45E13A

View File

@ -160,8 +160,10 @@ class EncryptedFileProvider(context: Context) {
exportedFile: ExportedFile,
encryptedVolume: EncryptedVolume,
): Boolean {
val fd = exportedFile.open(ParcelFileDescriptor.MODE_WRITE_ONLY, false).fileDescriptor
return encryptedVolume.exportFile(exportedFile.path, FileOutputStream(fd))
val pfd = exportedFile.open(ParcelFileDescriptor.MODE_WRITE_ONLY, false)
return encryptedVolume.exportFile(exportedFile.path, FileOutputStream(pfd.fileDescriptor)).also {
pfd.close()
}
}
enum class Error {