Skip to content

fix(files): map files on filesystems that cannot lock - #1965

Merged
CyberTimon merged 1 commit into
CyberTimon:mainfrom
prosthetiknow:fix/portal-file-lock
Oct 19, 2026
Merged

CyberTimon merged 1 commit into
CyberTimon:mainfrom
prosthetiknow:fix/portal-file-lock

Conversation

@prosthetiknow

Copy link
Copy Markdown
Contributor

Description

Under Flatpak, RapidRAW opens folders through the document portal, and flock there returns ENOSYS. read_file_mapped treats every try_lock_shared error as a lock held by another process, so no file opened through the portal can be mapped, and the log shows File is locked for each one. Every caller then falls back:

  • Thumbnails skip the embedded preview and decode the full raw. On a folder of 100 MP Fujifilm RAFs, four thumbnail workers managed about one thumbnail a second.
  • as_shot_white_balance returns the D65 reference, so the temperature and tint sliders and the picker start from the wrong baseline.
  • Editor loads copy the whole file into memory instead of mapping it.

The Flathub build has no filesystem permission, so this affects every Flathub user. flatpak override --filesystem=<folder> works around it today.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Performance improvement
  • Code refactoring
  • Documentation update
  • UI/UX improvement
  • Build/CI or Dependency update

Changes Made

  • read_file_mapped counts only TryLockError::WouldBlock as locked. Any other lock error, such as a filesystem that cannot lock, maps the file unlocked.

Screenshots/Videos

None. The change shows in the log.

Testing

  • These changes were tested locally by a human and confirmed to work.
  • I haven't added any automated tests to the code because the codebase currently lacks a test suite.

Test Configuration:

  • OS: Fedora 44, GNOME 50.6 on Wayland, the app built as a Flatpak on the GNOME 51 runtime with Flathub's permissions
  • Hardware: ThinkPad X1 Carbon Gen 14, Intel Core Ultra X7 358H, Intel Arc B390
  • Files: Fujifilm GFX100 II RAF, 11648×8736, opened through the document portal

Before, every RAF logged File is locked and each thumbnail decoded the full raw. After, the same folder logged no lock warnings and built 505 thumbnails from the embedded previews, each in milliseconds.

Checklist

  • My code follows the project's code style
  • I haven't added unnecessary AI-generated code comments
  • My changes generate no new warnings or errors

Additional Notes

This is independent of #1960 and applies on its own.

AI Disclaimer:

Please state the involvement of AI in this PR:

  • This PR is created by an AI agent
  • This PR is mostly AI-generated but edited/merged together by a human
  • This PR was handwritten with AI assistance (spell check, logic suggestions, error resolving)
  • This PR contains only blood, sweat, and coffee (AI-free)

read_file_mapped treated every try_lock_shared error as a lock held by
another process. The Flatpak document portal answers flock with ENOSYS,
so no file opened through it could be mapped. Thumbnails then decoded
the full raw instead of the embedded preview, and as_shot_white_balance
fell back to the D65 reference, which moved the baseline of the white
balance sliders and picker.

Only WouldBlock counts as locked now.
@CyberTimon

Copy link
Copy Markdown
Owner

LGTM, thanks so much!

@CyberTimon
CyberTimon merged commit 454789b into CyberTimon:main Oct 19, 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