Fix unhandled monitor initialisation exception

* Catch MonitorException when initialisation failure occurs, print error and exit ... cant enter monitor loop if we cant initialise correctly.
This commit is contained in:
abraunegg 2019-10-30 06:32:17 +11:00
parent fec892b038
commit e1be2b1e55

View file

@ -671,8 +671,17 @@ int main(string[] args)
signal(SIGINT, &exitHandler);
signal(SIGTERM, &exitHandler);
// initialise the monitor class
if (!cfg.getValueBool("download_only")) m.init(cfg, cfg.getValueLong("verbose") > 0, cfg.getValueBool("skip_symlinks"), cfg.getValueBool("check_nosync"));
// attempt to initialise monitor class
try {
m.init(cfg, cfg.getValueLong("verbose") > 0, cfg.getValueBool("skip_symlinks"), cfg.getValueBool("check_nosync"));
} catch (MonitorException e) {
// monitor initialisation failed
log.error("ERROR: ", e.msg);
exit(-1);
}
//if (!cfg.getValueBool("download_only")) m.init(cfg, cfg.getValueLong("verbose") > 0, cfg.getValueBool("skip_symlinks"), cfg.getValueBool("check_nosync"));
if (!cfg.getValueBool("download_only")) {
// monitor loop
immutable auto checkInterval = dur!"seconds"(cfg.getValueLong("monitor_interval"));
immutable auto logInterval = cfg.getValueLong("monitor_log_frequency");
@ -740,6 +749,7 @@ int main(string[] args)
}
}
}
}
// Workaround for segfault in std.net.curl.Curl.shutdown() on exit
oneDrive.http.shutdown();