Skip to content

Commit 5bdfffa

Browse files
authored
fix: infinite dialogs with network mount failure (#1956)
Selecting a broken network mount triggers an infinite loop of dialogs that requires killing the app: 1. Click invalid network mount 2. Try to mount network path 3. Show failure dialog 4. Trigger `NetworkDriveOpenEntityAfterMount` * BUG: This fires even if the mount failed or the user canceled the dialog! 6. Goto 2 Fix by having `network_drive(...)` return a Boolean indicating whether the mount actually happened and using that to break the infinite error loop. Fixes #1629 Sample broken network path that triggers the infinite dialog when selected: **~/.config/cosmic/com.system76.CosmicFiles/v1/favorites** ```ron [ Home, Documents, Downloads, Network( uri: "sftp://myserver/shared", name: "", path: "/tmp/fake-network/sftp-host=myserver/mnt", ), ] ``` - [x] I have disclosed use of any AI generated code in my commit messages. - [x] I understand these changes in full and will be able to respond to review comments. - [x] My change is accurately described in the commit message. - [x] My contribution is tested and working as described. - [x] I have read the [Developer Certificate of Origin](https://developercertificate.org/) and certify my contribution under its conditions.
2 parents 24e34ea + 9503516 commit 5bdfffa

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/app.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,10 +2678,14 @@ impl Application for App {
26782678
})
26792679
&& let Some(mounter) = MOUNTERS.get(&key)
26802680
{
2681-
return mounter.network_drive(uri.clone()).map(move |()| {
2682-
cosmic::Action::App(Message::NetworkDriveOpenEntityAfterMount {
2683-
entity,
2684-
})
2681+
return mounter.network_drive(uri.clone()).map(move |mounted| {
2682+
if mounted {
2683+
cosmic::Action::App(Message::NetworkDriveOpenEntityAfterMount {
2684+
entity,
2685+
})
2686+
} else {
2687+
cosmic::action::none()
2688+
}
26852689
});
26862690
}
26872691

@@ -3586,7 +3590,7 @@ impl Application for App {
35863590
Some((*mounter_key, self.network_drive_input.clone()));
35873591
return mounter
35883592
.network_drive(self.network_drive_input.clone())
3589-
.map(|()| cosmic::action::none());
3593+
.map(|_| cosmic::action::none());
35903594
}
35913595
log::warn!(
35923596
"no mounter found for connecting to {:?}",

src/mounter/gvfs.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl Mounter for Gvfs {
659659
)
660660
}
661661

662-
fn network_drive(&self, uri: String) -> Task<()> {
662+
fn network_drive(&self, uri: String) -> Task<bool> {
663663
let command_tx = self.command_tx.clone();
664664
Task::perform(
665665
async move {
@@ -668,9 +668,15 @@ impl Mounter for Gvfs {
668668
command_tx.send(Cmd::NetworkDrive(uri, res_tx)).unwrap();
669669
res_rx.await
670670
},
671-
|x| {
672-
if let Err(err) = x {
671+
|result| match result {
672+
Ok(Ok(())) => true,
673+
Ok(Err(err)) => {
674+
log::error!("{err:?}");
675+
false
676+
}
677+
Err(err) => {
673678
log::error!("{err:?}");
679+
false
674680
}
675681
},
676682
)

src/mounter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub trait Mounter: Send + Sync {
114114
fn items(&self, sizes: IconSizes) -> Option<MounterItems>;
115115
//TODO: send result
116116
fn mount(&self, item: MounterItem) -> Task<()>;
117-
fn network_drive(&self, uri: String) -> Task<()>;
117+
fn network_drive(&self, uri: String) -> Task<bool>;
118118
fn network_scan(&self, uri: &str, sizes: IconSizes) -> Option<Result<Vec<tab::Item>, String>>;
119119
fn dir_info(&self, uri: &str) -> Option<(String, String, Option<PathBuf>)>;
120120
fn unmount(&self, item: MounterItem) -> Task<()>;

0 commit comments

Comments
 (0)