mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 02:20:21 +00:00
Android: fix temp file leak in CameraHandler.handleClip (#41890)
* Android: fix temp file leak in CameraHandler.handleClip When readBytes() throws (IOException, OOM, etc.), the recorded clip file was never deleted because delete() only ran on the success path. Move file.delete() into a finally block so the temp file is cleaned up regardless of whether readBytes() succeeds or fails. Made-with: Cursor * fix: Android camera clip cleanup (#41890) (thanks @Kaneki-x) --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
This commit is contained in:
@@ -134,9 +134,11 @@ class CameraHandler(
|
||||
}
|
||||
|
||||
val bytes = withContext(Dispatchers.IO) {
|
||||
val b = filePayload.file.readBytes()
|
||||
filePayload.file.delete()
|
||||
b
|
||||
try {
|
||||
filePayload.file.readBytes()
|
||||
} finally {
|
||||
filePayload.file.delete()
|
||||
}
|
||||
}
|
||||
val base64 = android.util.Base64.encodeToString(bytes, android.util.Base64.NO_WRAP)
|
||||
clipLog("returning base64 payload")
|
||||
|
||||
Reference in New Issue
Block a user