feat: support search in network locations via GIO - #2032
Conversation
|
Two things from the same corner, both from reading the diff — I have not run this branch. Shares in a server listing look like they will be skipped. Overlap, unrelated to the above: the |
Good catch, you were right on both. Fixed in 881c8fd -- search now requests target-uri and descends into mountable entries. Typing to search on a server view now works, assuming the share(s) are mounted. Unmounted shares are silently skipped, so no mount prompts. And yeah, happy to rebase my search_set changes if #1966 lands first. |
Searching (including type-to-search) previously did nothing when browsing a network location without a gvfs-fuse path, such as shares opened through the Networks page or a URI typed into the location bar, because no SearchLocation could be derived for them. Add SearchLocation::Network and a gvfs mounter backend that searches recursively over the location URI with GIO enumerate_children, the same approach scan_path already uses for listing gvfs mounts. This works without gvfs-fuse, is faster than walking the fuse path since entries arrive in batches without per-file stat round trips, and returns to the network view when the search is cleared. The network:/// browse tree is excluded since its entries are servers that may not be mounted. This change was developed with AI assistance. I have reviewed and tested the changes and understand them in full.
Shares below a server URI such as smb://server/ are reported by gvfs as mountable entries, not directories, and their canonical location is only available in the standard::target-uri attribute. The search traversal only queued directories, so a search started from a server view matched share names without descending into any share. Request target-uri during search enumeration and queue mountable entries via their resolved URI. Mounted shares are now searched recursively; enumerating an unmounted share fails with NotMounted and is skipped, so no mount prompts are triggered. Also track visited URIs to guard against traversal cycles now that redirects are followed. Verified against a samba container: gio reports the share as mountable with a target-uri, search from the server view now recurses into the mounted share, and completes cleanly with only the share name match when the share is unmounted. This change was developed with AI assistance. I have reviewed and tested the changes and understand them in full.
68bd464 to
881c8fd
Compare
Problem
Network share search is broken in two ways:
shares opened from the Networks page or a URI typed into the location
bar. No
SearchLocationcan be derived, so keystrokes are dropped.per-entry round trips through the FUSE layer, and each keystroke also
runs synchronous fuse I/O on the UI thread (
change_locationcallsLocation::normalize), which stalls behind the walker and locks upthe app.
Solution
Add
SearchLocation::Networkand a gvfsnetwork_searchthat recursivelyenumerates the location URI with GIO, the same approach
scan_pathalreadyuses for gvfs mounts (see #1996). Entries arrive in batches with metadata
instead of per-entry fuse round trips, which makes search on network shares
massively faster (see videos). The search location carries no local path,
so no fuse I/O runs on the UI thread and the freezes are gone. Works with
any GVFS backend, does not require gvfs-fuse, and clearing the search
returns to the network view instead of the raw gvfs path. The network:///
browse tree stays excluded since its entries may not be mounted.
Demos
New: type-to-search on a share opened via the Networks page (~1,700 movie
folders). Plus massive speed increase.
type_to_search.mp4
Old fuse-path search on the same share, mounted. Slow, with UI freezes:
slow-search.mp4
Testing Notes
local samba container with emulated latency
hidden files, early cancellation, result locations, symlink cycles
See below for reproducible way to set up network share with lots of files and artificially induced lag to test speedup.
QA: reproducible test environment (fake SMB movie share)
Generate a fake movie library and serve it over SMB with guest access
(sparse files, ~200K real disk usage), then add LAN NAS latency
(2 ms with 0.5 ms jitter, 300 mbit) so loopback speed does not mask
the behavior being tested:
Test steps:
smb://localhost/movies, connect as guest.Entering a URI this way is the case that was broken (network location
with no fuse path).
needle: search opens and finds the folder and needle.mkv.On master this does nothing.
.needle-hidden.srtappears as a third result.forced: 300 results stream in from nested Subs folders.master to see the fuse-path slowness and freezes.
Cleanup:
docker rm -f qa-smb && rm -rf /tmp/qa-movies