From 7598130650e3c05a40df43cae8328a893f0817d1 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 21 Apr 2025 13:21:02 -0600 Subject: [PATCH] Fall back to unmount if eject is not supported, fixes #941 --- src/mounter/gvfs.rs | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/mounter/gvfs.rs b/src/mounter/gvfs.rs index 78df185..c3861f2 100644 --- a/src/mounter/gvfs.rs +++ b/src/mounter/gvfs.rs @@ -428,16 +428,29 @@ impl Gvfs { continue; } - log::info!("unmount {}", name); - MountExt::eject_with_operation( - &mount, - gio::MountUnmountFlags::NONE, - gio::MountOperation::NONE, - gio::Cancellable::NONE, - move |result| { - log::info!("unmount {}: result {:?}", name, result); - }, - ); + if MountExt::can_eject(&mount) { + log::info!("eject {}", name); + MountExt::eject_with_operation( + &mount, + gio::MountUnmountFlags::NONE, + gio::MountOperation::NONE, + gio::Cancellable::NONE, + move |result| { + log::info!("eject {}: result {:?}", name, result); + }, + ); + } else { + log::info!("unmount {}", name); + MountExt::unmount_with_operation( + &mount, + gio::MountUnmountFlags::NONE, + gio::MountOperation::NONE, + gio::Cancellable::NONE, + move |result| { + log::info!("unmount {}: result {:?}", name, result); + }, + ); + } } } }