You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "erisu (via GitHub)" <gi...@apache.org> on 2026/09/16 05:34:47 UTC

Re: [PR] fix(android): clean up pending camera temp files on cancel/stop [cordova-plugin-camera]

erisu commented on code in PR #970:
URL: https://github.com/apache/cordova-plugin-camera/pull/970#discussion_r4022532674


##########
src/android/CameraLauncher.java:
##########
@@ -1214,6 +1219,37 @@ private void cleanup(Uri oldImage, Uri newImage, Bitmap bitmap) {
         System.gc();
     }
 
+    /**
+     * Best-effort cleanup for temporary files when capture/selection is cancelled or stopped.
+     */
+    private void cleanupPendingResultFiles() {
+        deleteIfExists(this.imageUri);

Review Comment:
   I think the `imageUri` contains a `content://` URI, and the `deleteIfExists` method which uses `new File(filePath).delete()` would not work as it expects a filesystem path.
   
   I believe we would need to use the `ContentResolver` to delete the file by passing in the `imageUri`.



##########
src/android/CameraLauncher.java:
##########
@@ -1214,6 +1219,37 @@ private void cleanup(Uri oldImage, Uri newImage, Bitmap bitmap) {
         System.gc();
     }
 
+    /**
+     * Best-effort cleanup for temporary files when capture/selection is cancelled or stopped.
+     */
+    private void cleanupPendingResultFiles() {
+        deleteIfExists(this.imageUri);
+        deleteIfExists(this.croppedUri);

Review Comment:
   In this case, I think `croppedUri` is not a content URI so it is correct.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org