mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
Improve error handling upon watch directory setup (#4355)
Failing to handle the exception may lead to a critical log message (minor) and a crash during startup (major).
This commit is contained in:
@@ -740,15 +740,27 @@ void Session::Impl::watchdir_update()
|
|||||||
monitor_.reset();
|
monitor_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_enabled && monitor_ == nullptr)
|
if (!is_enabled || monitor_ != nullptr)
|
||||||
{
|
{
|
||||||
auto const m = dir->monitor_directory();
|
return;
|
||||||
watchdir_scan();
|
|
||||||
|
|
||||||
monitor_ = m;
|
|
||||||
monitor_dir_ = dir;
|
|
||||||
monitor_tag_ = m->signal_changed().connect(sigc::mem_fun(*this, &Impl::on_file_changed_in_watchdir));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto monitor = Glib::RefPtr<Gio::FileMonitor>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
monitor = dir->monitor_directory();
|
||||||
|
}
|
||||||
|
catch (Glib::Error const&)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
watchdir_scan();
|
||||||
|
|
||||||
|
monitor_ = monitor;
|
||||||
|
monitor_dir_ = dir;
|
||||||
|
monitor_tag_ = monitor_->signal_changed().connect(sigc::mem_fun(*this, &Impl::on_file_changed_in_watchdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
|||||||
Reference in New Issue
Block a user