Skip to content

fix(fs): fix crash on getting file descriptor from android content uri#3236

Open
aiueo13 wants to merge 2 commits intotauri-apps:v2from
aiueo13:update-getting-file-descriptor-from-android-content-uri
Open

fix(fs): fix crash on getting file descriptor from android content uri#3236
aiueo13 wants to merge 2 commits intotauri-apps:v2from
aiueo13:update-getting-file-descriptor-from-android-content-uri

Conversation

@aiueo13
Copy link
Copy Markdown
Contributor

@aiueo13 aiueo13 commented Jan 26, 2026

Fixes a crash that occurs when opening a file from an Android Content URI due to missing permissions or the file not existing.

Details

Before the fix, Kotlin’s getFileDescriptor function would return null when the file was unavailable.

val fd = activity.contentResolver.openAssetFileDescriptor(
Uri.parse(args.uri),
args.mode
)?.parcelFileDescriptor?.detachFd()
res.put("fd", fd)

However, on the Rust side that receives it, null triggers unimplemented!(), causing a panic.

if let Some(fd) = result.fd {
Ok(unsafe {
use std::os::fd::FromRawFd;
std::fs::File::from_raw_fd(fd)
})
} else {
unimplemented!()
}

And with this PR, the getFileDescriptor function will throw an error instead of returning null when the file is not available.

@aiueo13 aiueo13 requested a review from a team as a code owner January 26, 2026 09:21
@aiueo13 aiueo13 changed the title fix(fs): update getting file descriptor from android content uri fix(fs): fix crash on getting file descriptor from android content uri Jan 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Changes Through b710350

There are 10 changes which include updater with minor, updater-js with minor, barcode-scanner with patch, barcode-scanner-js with patch, fs with patch, fs-js with patch, http with patch, http-js with patch, sql with patch, sql-js with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 2.0.40 2.0.41
api-example-js 2.0.36 2.0.37
barcode-scanner 2.4.3 2.4.4
barcode-scanner-js 2.4.3 2.4.4
fs 2.4.5 2.4.6
fs-js 2.4.5 2.4.6
dialog 2.6.0 2.6.1
dialog-js 2.6.0 2.6.1
http 2.5.6 2.5.7
http-js 2.5.6 2.5.7
persisted-scope 2.3.5 2.3.6
sql 2.3.1 2.3.2
sql-js 2.3.1 2.3.2
updater 2.9.0 2.10.0
updater-js 2.9.0 2.10.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master Legend-Master added the platform: android Android specific issues label Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: android Android specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants