feat(library): detect network-mounted tracks at index time
Adds an is_network_mount flag to local_tracks. Populated by reading
/proc/mounts (falling back to /run/host/proc/mounts for Flatpak
sandboxes) and matching the file path's longest-prefix mount against
a list of network filesystems — nfs/nfs4, cifs/smb/smb3, fuse.sshfs,
fuse.rclone, fuse.gvfs, davfs/webdav, 9p, ceph, glusterfs, afs, afp.
Motivation: the earlier offline-awareness commit used a frontend
heuristic that matched /mnt, /media, /run/media and Windows UNC. That
catches the classic cases but misses the common sandbox case — a user
on Flathub or Snap mounts their NAS via GVFS at /run/user/1000/gvfs/…
or bind-mounts it into /home/user/music, and neither of those
triggers the frontend check. The backend sees the mount type
directly, so flagging the row at index time gives the UI ground truth.
Changes:
* new crates/qbz-library/src/mount_info.rs — is_network_path(&Path)
helper with /proc/mounts parsing, longest-prefix mount matching,
and a NETWORK_FS_PREFIXES list. Guarded with cfg(target_os =
"linux"); stubs return false on macOS / Windows (frontend keeps
its string-match heuristic there).
* LocalTrack gains is_network_mount: bool (serialized camelCase).
* local_tracks table: new is_network_mount INTEGER NOT NULL DEFAULT
0 column, both in the initial CREATE TABLE and a migration for
existing DBs.
* insert_track calls mount_info::is_network_path(&track.file_path)
and writes the flag. Qobuz cached-download inserts rely on the
column default (always 0) since those land inside the app's own
data dir.
* TRACK_COLUMNS + row_to_track pick up the new column. The two
inline LocalTrack builders in get_playlist_local_tracks and
get_playlist_local_tracks_with_position are updated the same way,
plus the playlist_position index shifts by one.
cc
This commit is contained in:
6 files changed
+227
-7
No files matched your search
@@ -76,6 +76,15 @@ pub struct LocalTrack {
|
||||
// Download tracking
|
||||
pub source: Option<String>,
|
||||
pub qobuz_track_id: Option<i64>,
|
||||
|
||||
/// True when the file lives on a network-backed filesystem (NFS,
|
||||
/// CIFS/SMB, SSHFS, etc.). Detected at index time by inspecting
|
||||
/// /proc/mounts. Consumed by the UI to mark the track as
|
||||
/// unreachable under forced offline mode — cable unplugged means
|
||||
/// the mount is gone even if the path string still says /home/…,
|
||||
/// which is common under Flatpak / Snap sandboxes.
|
||||
#[serde(default)]
|
||||
pub is_network_mount: bool,
|
||||
}
|
||||
|
||||
impl Default for LocalTrack {
|
||||
@@ -108,6 +117,7 @@ impl Default for LocalTrack {
|
||||
indexed_at: 0,
|
||||
source: None,
|
||||
qobuz_track_id: None,
|
||||
is_network_mount: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user