Skip to content

fix(SafHelper): delete orphaned empty file when FD open fails after creation - #116

Closed
joselofarias-byte wants to merge 1 commit into
kitsumed:mainfrom
joselofarias-byte:agent/upstream-port-20260813-recon
Closed

joselofarias-byte wants to merge 1 commit into
kitsumed:mainfrom
joselofarias-byte:agent/upstream-port-20260813-recon

Conversation

@joselofarias-byte

Copy link
Copy Markdown

Summary

  • Reconciled a stale local branch against upstream main (fast-forward, no unique prior commits) after full inspection of the recording/call-detection/permission pipeline.
  • Found and fixed one genuine bug in SafHelper.createAudioFile(): if ContentResolver.openFileDescriptor() fails after the SAF document was already created via DocumentFile.createFile(), the code returned null without deleting the just-created document, leaving an orphaned, empty, untracked file behind in the user's chosen recordings folder on every such failure. The fix deletes the orphaned DocumentFile before returning null.

Testing

  • SKIP_SIGNING=true ./gradlew assembleDebug --stacktrace --no-daemon — BUILD SUCCESSFUL.
  • Not tested on a physical device: the actual openFileDescriptor failure path (would require forcing a transient SAF/DocumentsProvider error), and a general end-to-end recording session sanity check.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G8GvrjdRj8AM6ag4rsGsbH

…reation

createAudioFile() created the SAF document via createFile() but returned
null without cleanup if the subsequent openFileDescriptor() call failed
(e.g. a transient SAF/DocumentsProvider glitch). The empty document was
never tracked by AudioRecordingEngine (currentRecordingUri is only set
after a successful SafResult), so it silently accumulated in the user's
recordings folder on every occurrence.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G8GvrjdRj8AM6ag4rsGsbH
@kitsumed

kitsumed commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

Hi, do you have any error/logs that prove this is an issue? I don't remember ever hitting this during my tests, when it failed it did not make a file since it failed.

I am asking because I cannot check the claude session to see more.

Also, please edit the commit so it is authored by @joselofarias-byte and has Assisted-by: Claude Sonnet 5 in its message as per CONTRIBUTING.md.

@kitsumed kitsumed closed this Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants