Commit b7d0f073 authored by Michael Gratton's avatar Michael Gratton 🤞

Fix spurious "Can't reach host" running under Flatpak, maybe elsewhere

When offline, the GLib.NetworkMonitor portal implementation will throw a
GLib.IOError.HOST_UNREACHABLE error instead of returning false. Handle
this case explicitly and treat it as being unreachable, not an error.

See #266
parent 224ccb18
Pipeline #64991 passed with stages
in 16 minutes and 50 seconds
......@@ -115,6 +115,23 @@ public class Geary.ConnectivityManager : BaseObject {
);
} catch (GLib.IOError.CANCELLED err) {
// User cancelled, so leave as unreachable
} catch (GLib.IOError.HOST_UNREACHABLE err) {
// Despite returning a boolean, per its API docs
// NetworkMonitor.can_reach() should never actually return
// false under Vala since it will throw an error instead,
// and usually this one. While that's not 100% always the
// case, we do need to treat this error as meaning
// unreachable.
//
// However if the monitor says there actually is a network
// available, we may be running under Flatpak with Network
// Manager connectivity checking enabled and hitting issue
// GNOME/glib#1705. Pull this debug logging out once that
// is fixed.
if (this.monitor.network_available) {
debug("Assuming %s is unreachable, despite network availability",
endpoint);
}
} catch (GLib.DBusError err) {
// Running under Flatpak can cause a DBus error if the
// portal is malfunctioning (e.g. Geary #97 & #82 and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment