Skip to content

fix: fall back to GIO on destination open failure for MTP copies - #1923

Merged
jacobgkau merged 6 commits into
pop-os:masterfrom
nalladev:fix/mtp-copy-gio-fallback
Jul 15, 2026
Merged

jacobgkau merged 6 commits into
pop-os:masterfrom
nalladev:fix/mtp-copy-gio-fallback

Conversation

@nalladev

@nalladev nalladev commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

When copying files to an MTP device mounted via GVfs FUSE, compio's io_uring backend fails to open the destination file with O_CREAT|O_EXCL. The existing gio_file_copy fallback only triggered on write_at failures, so the error propagated before GIO was ever tried.

Now, if the destination open fails via compio, we fall back to gio_file_copy (which uses POSIX I/O through GIO), matching the same fallback pattern already used for write_at Unsupported errors.

Fixes #1782

  • I have disclosed use of any AI generated code in my commit messages.
    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

When copying files to an MTP device mounted via GVfs FUSE, compio's
io_uring backend fails to open the destination file with O_CREAT|O_EXCL.
The existing gio_file_copy fallback only triggered on write_at failures,
so the error propagated before GIO was ever tried.

Now, if the destination open fails via compio, we fall back to
gio_file_copy (which uses POSIX I/O through GIO), matching the same
fallback pattern already used for write_at Unsupported errors.
Comment thread src/operation/recursive.rs Resolved
Comment thread src/operation/recursive.rs Resolved
Comment thread src/operation/recursive.rs Resolved
nalladev added 2 commits July 15, 2026 19:00
Use .with_context() instead of anyhow::anyhow! so the original io::Error
is preserved in the error chain, matching reviewer feedback on pop-os#1923.
mmstick
mmstick previously approved these changes Jul 15, 2026
@jacobgkau jacobgkau self-assigned this Jul 15, 2026
jacobgkau
jacobgkau previously approved these changes Jul 15, 2026

@jacobgkau jacobgkau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like Michael, I also wasn't able to recreate any MTP issues with my own Android devices, but I'm not seeing any regressions with MTP, either.

Standard regression testing passed:

Checklist

Basic navigation

  • Middle-click opens directory in a new tab (not focused).
  • Open two scrollable tabs. Scroll one tab, then switch to the other tab; it should not have scrolled.
  • Hover over the top item in the folder, then scroll down until it's out of view (while still hovered). On scrolling back up (with the mouse in a different position), the item should not have the hover highlight.
  • Right-click an item in the sidebar. No visual change should occur with the rest of the items.
  • Remove an item from the sidebar, then re-pin it.

File operations

  • Right-click -> Create a new folder, then enter it.
  • Right-click in the empty folder -> Create a new file.
  • Navigate to the parent folder, create another new file, then drag it into the created folder.
  • Files can be renamed.
  • Files can be opened with non-default apps & browsing store for new apps works.
  • Normal right-click shows Move to trash option.
  • Shift right-click, and right-click followed by Shift, both show Permanently delete option.

Advanced navigation & view settings

  • Image and video thumbnails generate & display in local folders.
  • Gallery preview shows with Spacebar.
  • Details pane shows with Ctrl+Spacebar.
  • Zoom in/out and reset to default zoom work.
  • Ctrl+1 and Ctrl+2 switch between list and icon view.
  • Ctrl+H shows/hides hidden files.
  • Directories can be sorted at top or inline.
  • Settings -> Theme works.
  • Settings -> Type to Search affects behavior as designed.
  • Single-click to open setting takes effect.
  • Recents in sidebar setting works.
  • Sorting options work.
  • Cutting, copying, and pasting files works.
  • F5 reloads current directory.
  • Left sidebar can be collapsed and expanded.

External filesystems

  • Add a network drive (e.g. SFTP) and navigate into it.
  • Plug in a USB drive; able to mount, browse, and eject.

Integrations

  • Desktop icons display as expected
  • Drag-and-drop into Firefox works

@jacobgkau
jacobgkau dismissed their stale review July 15, 2026 17:11

CI failed

@jacobgkau

Copy link
Copy Markdown
Member

It does look like the Cargo Build & Test check has failed, even though this compiled successfully on my test machine. I guess I'll try having the build server built it.

Add .map_err(Into::into) to convert anyhow::Error to Box<dyn Error>
matching the function's return type.

@jacobgkau jacobgkau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI's working now. Testing looks the same as before.

Regression testing passed again:

Checklist

Basic navigation

  • Middle-click opens directory in a new tab (not focused).
  • Open two scrollable tabs. Scroll one tab, then switch to the other tab; it should not have scrolled.
  • Hover over the top item in the folder, then scroll down until it's out of view (while still hovered). On scrolling back up (with the mouse in a different position), the item should not have the hover highlight.
  • Right-click an item in the sidebar. No visual change should occur with the rest of the items.
  • Remove an item from the sidebar, then re-pin it.

File operations

  • Right-click -> Create a new folder, then enter it.
  • Right-click in the empty folder -> Create a new file.
  • Navigate to the parent folder, create another new file, then drag it into the created folder.
  • Files can be renamed.
  • Files can be opened with non-default apps & browsing store for new apps works.
  • Normal right-click shows Move to trash option.
  • Shift right-click, and right-click followed by Shift, both show Permanently delete option.

Advanced navigation & view settings

  • Image and video thumbnails generate & display in local folders.
  • Gallery preview shows with Spacebar.
  • Details pane shows with Ctrl+Spacebar.
  • Zoom in/out and reset to default zoom work.
  • Ctrl+1 and Ctrl+2 switch between list and icon view.
  • Ctrl+H shows/hides hidden files.
  • Directories can be sorted at top or inline.
  • Settings -> Theme works.
  • Settings -> Type to Search affects behavior as designed.
  • Single-click to open setting takes effect.
  • Recents in sidebar setting works.
  • Sorting options work.
  • Cutting, copying, and pasting files works.
  • F5 reloads current directory.
  • Left sidebar can be collapsed and expanded.

External filesystems

  • Add a network drive (e.g. SFTP) and navigate into it.
  • Plug in a USB drive; able to mount, browse, and eject.

Integrations

  • Desktop icons display as expected
  • Drag-and-drop into Firefox works

@jacobgkau
jacobgkau merged commit a93fc1d into pop-os:master Jul 15, 2026
8 checks passed
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.

Cannot copy files from Linux to Android device over MTP (write fails)

3 participants