fix infinite dialog on network mount failure

This commit is contained in:
Will Sheehan 2026-08-04 23:09:19 -07:00
parent 24e34eaa0f
commit 95035166d3
3 changed files with 19 additions and 9 deletions

View file

@ -2678,10 +2678,14 @@ impl Application for App {
}) })
&& let Some(mounter) = MOUNTERS.get(&key) && let Some(mounter) = MOUNTERS.get(&key)
{ {
return mounter.network_drive(uri.clone()).map(move |()| { return mounter.network_drive(uri.clone()).map(move |mounted| {
cosmic::Action::App(Message::NetworkDriveOpenEntityAfterMount { if mounted {
entity, cosmic::Action::App(Message::NetworkDriveOpenEntityAfterMount {
}) entity,
})
} else {
cosmic::action::none()
}
}); });
} }
@ -3586,7 +3590,7 @@ impl Application for App {
Some((*mounter_key, self.network_drive_input.clone())); Some((*mounter_key, self.network_drive_input.clone()));
return mounter return mounter
.network_drive(self.network_drive_input.clone()) .network_drive(self.network_drive_input.clone())
.map(|()| cosmic::action::none()); .map(|_| cosmic::action::none());
} }
log::warn!( log::warn!(
"no mounter found for connecting to {:?}", "no mounter found for connecting to {:?}",

View file

@ -659,7 +659,7 @@ impl Mounter for Gvfs {
) )
} }
fn network_drive(&self, uri: String) -> Task<()> { fn network_drive(&self, uri: String) -> Task<bool> {
let command_tx = self.command_tx.clone(); let command_tx = self.command_tx.clone();
Task::perform( Task::perform(
async move { async move {
@ -668,9 +668,15 @@ impl Mounter for Gvfs {
command_tx.send(Cmd::NetworkDrive(uri, res_tx)).unwrap(); command_tx.send(Cmd::NetworkDrive(uri, res_tx)).unwrap();
res_rx.await res_rx.await
}, },
|x| { |result| match result {
if let Err(err) = x { Ok(Ok(())) => true,
Ok(Err(err)) => {
log::error!("{err:?}"); log::error!("{err:?}");
false
}
Err(err) => {
log::error!("{err:?}");
false
} }
}, },
) )

View file

@ -114,7 +114,7 @@ pub trait Mounter: Send + Sync {
fn items(&self, sizes: IconSizes) -> Option<MounterItems>; fn items(&self, sizes: IconSizes) -> Option<MounterItems>;
//TODO: send result //TODO: send result
fn mount(&self, item: MounterItem) -> Task<()>; fn mount(&self, item: MounterItem) -> Task<()>;
fn network_drive(&self, uri: String) -> Task<()>; fn network_drive(&self, uri: String) -> Task<bool>;
fn network_scan(&self, uri: &str, sizes: IconSizes) -> Option<Result<Vec<tab::Item>, String>>; fn network_scan(&self, uri: &str, sizes: IconSizes) -> Option<Result<Vec<tab::Item>, String>>;
fn dir_info(&self, uri: &str) -> Option<(String, String, Option<PathBuf>)>; fn dir_info(&self, uri: &str) -> Option<(String, String, Option<PathBuf>)>;
fn unmount(&self, item: MounterItem) -> Task<()>; fn unmount(&self, item: MounterItem) -> Task<()>;