Merge pull request #1379 from FreddyFunk/bugfix/external-drives-metadata

Show metadata, thumbnails and gallery view on mounted drives
This commit is contained in:
Jeremy Soller 2025-11-18 16:52:35 -07:00 committed by GitHub
commit 29a1f7f518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 92 additions and 7 deletions

View file

@ -33,15 +33,26 @@ fn items(monitor: &gio::VolumeMonitor, sizes: IconSizes) -> MounterItems {
let mut items: MounterItems = (monitor.mounts().into_iter())
.enumerate()
.map(|(i, mount)| {
let root = MountExt::root(&mount);
let is_remote = root
.query_filesystem_info(
gio::FILE_ATTRIBUTE_FILESYSTEM_REMOTE,
gio::Cancellable::NONE,
)
.ok()
.and_then(|info| Some(info.boolean(gio::FILE_ATTRIBUTE_FILESYSTEM_REMOTE)))
.unwrap_or(true); // Default to remote if query fails
MounterItem::Gvfs(Item {
uri: mount.root().uri().into(),
kind: ItemKind::Mount,
index: i,
name: mount.name().into(),
is_mounted: true,
is_remote,
icon_opt: gio_icon_to_path(&MountExt::icon(&mount), sizes.grid()),
icon_symbolic_opt: gio_icon_to_path(&MountExt::symbolic_icon(&mount), 16),
path_opt: MountExt::root(&mount).path(),
path_opt: root.path(),
})
})
.collect();
@ -61,6 +72,7 @@ fn items(monitor: &gio::VolumeMonitor, sizes: IconSizes) -> MounterItems {
index: i,
name: volume.name().into(),
is_mounted: false,
is_remote: false,
icon_opt: gio_icon_to_path(&VolumeExt::icon(&volume), sizes.grid()),
icon_symbolic_opt: gio_icon_to_path(&VolumeExt::symbolic_icon(&volume), 16),
path_opt: None,
@ -283,6 +295,7 @@ pub struct Item {
index: usize,
name: String,
is_mounted: bool,
is_remote: bool,
icon_opt: Option<PathBuf>,
icon_symbolic_opt: Option<PathBuf>,
path_opt: Option<PathBuf>,
@ -297,6 +310,10 @@ impl Item {
self.is_mounted
}
pub const fn is_remote(&self) -> bool {
self.is_remote
}
pub fn uri(&self) -> String {
self.uri.clone()
}
@ -406,6 +423,7 @@ impl Gvfs {
let mount_op = mount_op(name.to_string(), event_tx.clone());
let event_tx = event_tx.clone();
let mounter_item = mounter_item.clone();
let volume_for_callback = volume.clone();
VolumeExt::mount(
&volume,
gio::MountMountFlags::NONE,
@ -413,7 +431,29 @@ impl Gvfs {
gio::Cancellable::NONE,
move |res| {
log::info!("mount {name}: result {res:?}");
event_tx.send(Event::MountResult(mounter_item, match res {
// Update the mounter_item with mount information after successful mount
let mut updated_item = mounter_item.clone();
if res.is_ok() {
if let MounterItem::Gvfs(ref mut item) = updated_item {
if let Some(mount) = volume_for_callback.get_mount() {
let root = MountExt::root(&mount);
item.path_opt = root.path();
item.is_mounted = true;
// Query if remote
item.is_remote = root
.query_filesystem_info(
gio::FILE_ATTRIBUTE_FILESYSTEM_REMOTE,
gio::Cancellable::NONE,
)
.ok()
.and_then(|info| {
Some(info.boolean(gio::FILE_ATTRIBUTE_FILESYSTEM_REMOTE))
})
.unwrap_or(true);
}
}
}
event_tx.send(Event::MountResult(updated_item, match res {
Ok(()) => {
_ = complete_tx.send(Ok(()));
Ok(true)

View file

@ -90,6 +90,14 @@ impl MounterItem {
Self::None => unreachable!(),
}
}
pub fn is_remote(&self) -> bool {
match self {
#[cfg(feature = "gvfs")]
Self::Gvfs(item) => item.is_remote(),
Self::None => unreachable!(),
}
}
}
pub type MounterItems = Vec<MounterItem>;