Skip to content

fix(open): fall back to the fast content type GVfs SMB reports - #1955

Merged
l0gicgate merged 5 commits into
lgse:mainfrom
wmfeht:fix/1944-smb-content-type
Nov 1, 2026
Merged

l0gicgate merged 5 commits into
lgse:mainfrom
wmfeht:fix/1944-smb-content-type

Conversation

@wmfeht

@wmfeht wmfeht commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

GVfs's SMB backend sets standard::content-type only when the name-based type guess is certain; for .md, .py, .json and other uncertain names it sets only standard::fast-content-type (daemon/gvfsbackendsmb.c, gvfs 1.62). Strata queried and read only standard::content-type, so opening such a file failed with "Unable to determine the selected file type" and GLib logged a GFileInfo created without standard::content-type critical. Open With, Properties (Kind / Opens with) and the text preview lost the type the same way.

A new adapters::content_type_of helper reads standard::content-type and falls back to standard::fast-content-type, as GLib's own g_file_query_default_handler does (which is why gio open worked). Every FileInfo type lookup now queries both attributes and uses it; checking has_attribute first also removes the critical.

Properties also read standard::is-hidden, which GVfs SMB sets only for hidden files, without checking it was present, logging a GFileInfo created without standard::is-hidden critical. It now uses the listing's existing info_is_hidden check.

The container QA environment has no SMB backend, and the local backend always sets standard::content-type, so the regression is covered by a unit test on the helper rather than a QA scenario.

Visual evidence

N/A — non-visual fix to file type resolution.

How to test

  1. Mount an SMB share through GVfs (gio mount smb://server/share) that contains a README.md, a .py and a .json file. Confirm gio info -a standard::content-type smb://server/share/README.md lists no content type.
  2. Browse to the share in Strata and double-click each file; also try Open With and Properties on them, and preview the .md.

Expected result: each file opens in its default application, Open With lists matching applications, Properties shows the file's Kind and "Opens with", the preview shows the text, and no GLib-GIO-CRITICAL appears in the log. .txt files keep working as before.

Related issue

Closes #1944

GVfs SMB sets only standard::fast-content-type when a name's type guess is
uncertain (.md, .py, .json), so opening, Open With, Properties and preview
lost the type and logged a GLib critical. Read it the way GLib's default
handler lookup does.

Fixes lgse#1944
@github-actions github-actions Bot added the fix label Oct 30, 2026
@wmfeht

wmfeht commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Manual testing on an SMB share

Tested against a GVfs-mounted Samba share (smb://home-nas.local/other, gvfs 1.62.0, GLib 2.90.1, Arch Linux) with a scratch folder containing README.md, script.py, data.json, and a notes.txt control. gio info confirmed that the share reports only standard::fast-content-type for the first three files, while notes.txt also has standard::content-type, which reproduces the condition from #1944.

  • main: opening README.md, script.py, and data.json failed with "Unable to determine the selected file type", which reproduces the bug.

  • This branch:

    • double-clicking opens all three in their default applications, and notes.txt still opens;
    • Open With lists matching applications;
    • Properties shows Kind and "Opens with";
    • previewing README.md shows its source text. Rendered Markdown is source-only on remote locations by design (docs/document-previews.md), so this PR doesn't change that.
  • Log: the GFileInfo created without standard::content-type critical no longer appears. A related critical still appears when Properties is opened for these files:

    GLib-GIO-CRITICAL **: GFileInfo created without standard::is-hidden
    GLib-GIO-CRITICAL **: file ../glib/gio/gfileinfo.c: line 1647 (g_file_info_get_is_hidden): should not be reached
    

    gvfs SMB sets standard::is-hidden only when it is true, and src/ui/browser/properties.rs calls FileInfo::is_hidden() without first checking that the attribute is present (the listing in src/adapters/local_files.rs already checks). The dialog still shows "No" correctly. This critical was already on main and isn't caused by this PR.

GVfs SMB sets standard::is-hidden only for hidden files, so FileInfo::is_hidden
logged a GLib critical in Properties for every other file. Use the listing's
existing info_is_hidden check.

Refs lgse#1944
@wmfeht

wmfeht commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

The standard::is-hidden critical noted above is addressed in 8b94784: Properties now uses the listing's existing info_is_hidden check, which reads the attribute only when the backend reports it. This has not yet been retested by hand on the SMB share.

@wmfeht

wmfeht commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Looks good. I found no blocking issues. The fix goes after the cause described in #1944, and I verified each change below by reading the code.

What I checked

  • Callers: No FileInfo::content_type() calls are left in src/. The five type lookups now use CONTENT_TYPE_ATTRIBUTES together with content_type_of: src/ui/browser/desktop.rs:110, src/ui/open_with.rs:255, src/ui/browser/properties.rs:836, src/ui/browser/properties/media.rs:143 and src/adapters/local_preview.rs:316. Opening a file, Open With, Properties, media metadata and the uncertain-name preview all get the fallback.
  • Matches GLib: content_type_of (src/adapters/gio_location.rs:51) tries standard::content-type first and falls back to standard::fast-content-type. That is the same order g_file_query_default_handler uses, which explains why gio open worked. On local files standard::content-type is always set, so local behaviour doesn't change. Adding fast-content-type to each query costs almost nothing.
  • Hidden state: Properties now calls the existing info_is_hidden (src/adapters/local_files.rs:479), which checks has_attribute before reading. The second critical from the manual test is therefore fixed without changing local results. A search finds no other unguarded is_hidden() call.
  • Tests: content_type_falls_back_to_the_fast_type_gvfs_smb_reports_for_uncertain_names (src/adapters/gio_location/tests.rs:99) is a real behaviour test, not a tautology. It covers which value wins when both are set, the fallback, and the case where neither is set. It sits in the adjacent tests.rs module, as AGENTS.md requires. A unit test instead of a QA scenario is reasonable: the container has no SMB backend, and the local backend always sets standard::content-type.
  • i18n / UI rules: No new user-facing strings ("Yes", "No" and the error messages already exist), and no keyboard, tooltip or theming changes.
  • CI: All required checks pass.

Nits

  • src/adapters/gio_location.rs:48-58: the doc comment and the has_attribute filter overstate their job. g_file_info_get_attribute_string returns NULL for a missing attribute without logging anything. Only typed getters like g_file_info_get_content_type log the "GFileInfo created without …" critical. The critical goes away because the code stops calling content_type(), not because of the has_attribute check. Either drop the filter and keep .find_map(|attribute| info.attribute_string(attribute)), or keep it and reword the last sentence. For example: "Reading the attributes generically, rather than through FileInfo::content_type, avoids the GLib critical that getter logs for a missing value."
  • Manual testing: The follow-up comment says 8b94784 (the is-hidden change) hasn't been retested by hand on the SMB share. The change is small and clearly correct. Still, a quick check that Properties no longer logs the standard::is-hidden critical would back up the PR's "How to test" claim that no GLib-GIO-CRITICAL appears.

@l0gicgate

Copy link
Copy Markdown
Contributor

Review

Merged main (8760486a) into the branch (clean, no conflicts) and reviewed the diff against it.

Verdict: no blocking issues. The fix matches GLib's own g_file_query_default_handler order, every former FileInfo::content_type() call site now goes through content_type_of with both attributes queried, and the listing never read the content type, so no other path is affected. info_is_hidden reuse in Properties is correct: the gio binding's attribute_string maps to g_file_info_get_attribute_string, which returns null silently, while content_type()/is_hidden() use the typed getters that log the critical.

Change made: 545a8211 tightens the two doc comments on the helper. The label-only comment on CONTENT_TYPE_ATTRIBUTES is dropped and the content_type_of doc keeps just the rationale (why the fallback exists and why the generic getter avoids the critical).

Feedback disposition:

  • The doc-comment nit from the earlier review comment was already addressed in 8c1c31aa and is now further tightened.
  • The is-hidden critical follow-up (8b947840) was reviewed and is correct; it has still not been retested by hand on an SMB share by me either. This host has no GVfs SMB backend or share available, so that retest remains open for anyone with a share.

Tests: the new table-driven unit test checks precedence, fallback and the missing case, so it was kept as is.

Local verification (pinned container, ./scripts/quality.sh all): cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, and the full Rust suite passed (3759 tests). Native scoped run of adapters::gio_location::, adapters::local_preview::tests::, ui::open_with::tests::, ui::browser::desktop::tests:: also passed (45 tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SMB files fail to open when standard::content-type is missing

2 participants