Skip to content

nautilus: resolve GVFS/SMB paths correctly and show clean URIs - #14

Open
mward5 wants to merge 1 commit into
ScooterSoftware:masterfrom
mward5:fix/nautilus-smb-context-menus
Open

nautilus: resolve GVFS/SMB paths correctly and show clean URIs#14
mward5 wants to merge 1 commit into
ScooterSoftware:masterfrom
mward5:fix/nautilus-smb-context-menus

Conversation

@mward5

@mward5 mward5 commented Aug 18, 2026

Copy link
Copy Markdown

The bug

nautilus_to_path() called g_filename_from_uri() directly on the file's URI. That function only understands file:// and returns NULL for anything GVFS-backed, so on smb:// (and sftp://, etc.) shares "Select Left File/Folder for Compare" silently captured nothing and the follow-up "Compare to" never worked.

The fix

Resolve the location through its GFile instead. For a GVFS mount with an active FUSE bridge this yields the real /run/user/<uid>/gvfs/... path that both file_is_dir() and bcompare need.

That path works but is unpleasant to look at in Beyond Compare's address bar, so it's converted back to the original URI at the single point where that matters — the argv handed to bcompare. path_to_display() maps a GVFS-backed path to its clean smb://server/share/... form and leaves local paths untouched.

Keeping the conversion at the argv boundary means everything upstream of it — the selection storage files, the menu-item data, and every file_is_dir() call including the delayed one that runs against a path round-tripped through LeftFileStorage on a later right-click — keeps working with real, stat()-able paths exactly as before. The on-disk format of the selection files is unchanged, and beyondcompare_get_file_items(), the BCompareExt struct, and all six *_mitem() builders are untouched.

Scope

Nautilus only. Thunar has the identical bug in bcompare-thunarx.c (thunarx_to_path()), but it's unverified here and belongs in its own change.

On the approach

An earlier version of this fix carried two parallel values (real path + display URI) through the struct, the menu items, and a two-line selection-file format. It works, but it's ~3x the diff and changes the storage format. It's preserved at alt/dual-value-carry for comparison.

Converting at the argv boundary turned out to be much simpler, mainly because GIO already performs the FUSE-path to URI mapping natively via g_file_new_for_commandline_arg() + g_file_get_uri() — no parsing of GVFS's internal mount naming is required, including for filenames containing commas, which that naming scheme uses as its own separator.

Testing

Verified against a live smb:// share, both the multi-select workflow and the two-step "Select Left..." then right-click "Compare to" workflow:

  • local file vs. local file — address bar unchanged from current behavior
  • local folder vs. local folder — still detected as folders
  • smb:// file vs. smb:// file
  • smb:// file vs. local file (cross-location, two-step)
  • smb:// folder compare — detected as a folder and shows the clean URI
  • filenames containing spaces and commas — no percent-escapes visible in the address bar
  • builds clean with make -C nautilus ext64 (only pre-existing GTK deprecation warnings)

@mward5
mward5 force-pushed the fix/nautilus-smb-context-menus branch from 6cd73be to de9335d Compare August 18, 2026 22:06
nautilus_to_path() called g_filename_from_uri() directly on the file's
URI, which only handles file:// schemes. For GVFS-backed locations
(smb://, sftp://, etc.) it returned NULL, so "Select Left File/Folder
for Compare" and "Compare to" silently failed for network shares.

Resolve the location through its GFile instead, which for a GVFS mount
with an active FUSE bridge yields the real /run/user/<uid>/gvfs/...
path that both file_is_dir() and bcompare need.

That path is correct but ugly to look at, so convert it back to the
original URI at the one point where it matters: the argv handed to
bcompare. path_to_display() maps a GVFS-backed path to its clean
smb://server/share/... form and leaves local paths untouched, so
Beyond Compare's address bar shows the network location the user
actually browsed rather than the FUSE mount point.

Keeping the conversion at the argv boundary means everything upstream
of it -- the selection storage files, the menu-item data, and every
file_is_dir() call including the delayed one that runs against a path
round-tripped through LeftFileStorage on a later right-click -- keeps
working with real, stat()-able paths exactly as before. Nothing else
in the extension has to know about URIs, and the on-disk format of the
selection files is unchanged.

Thunar has the identical unfixed bug in bcompare-thunarx.c but is
left untouched here, matching this fix's own verified/tested scope.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mward5
mward5 force-pushed the fix/nautilus-smb-context-menus branch from de9335d to 1332b00 Compare August 19, 2026 19:09
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.

1 participant