From e08f1934ec79646063430ca76af2640bf22e1284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sun, 11 Apr 2021 04:02:14 +1200 Subject: [PATCH] Simplify on_update code further --- src/run.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/run.rs b/src/run.rs index 2c7e759..6ce7c3f 100644 --- a/src/run.rs +++ b/src/run.rs @@ -229,33 +229,34 @@ impl Handler for ExecHandler { // Only returns Err() on lock poisoning. fn on_update(&self, ops: &[PathOp]) -> Result { + let signal = self.signal.unwrap_or(Signal::SIGTERM); + match ( self.has_running_process(), self.args.on_busy_update, - self.signal, ) { // If nothing is running, start the command - (false, _, _) => { + (false, _) => { self.spawn(ops)?; } // Just send a signal to the command, do nothing more - (true, OnBusyUpdate::Signal, signal) => signal_process(&self.child_process, signal.unwrap_or(Signal::SIGTERM)), + (true, OnBusyUpdate::Signal) => signal_process(&self.child_process, signal), // Send a signal to the command, wait for it to exit, then run the command again - (true, OnBusyUpdate::Restart, signal) => { - signal_process(&self.child_process, signal.unwrap_or(Signal::SIGTERM)); + (true, OnBusyUpdate::Restart) => { + signal_process(&self.child_process, signal); wait_on_process(&self.child_process); self.spawn(ops)?; } // Wait for the command to end, then run it again - (true, OnBusyUpdate::Queue, _) => { + (true, OnBusyUpdate::Queue) => { wait_on_process(&self.child_process); self.spawn(ops)?; } - (true, OnBusyUpdate::DoNothing, _) => {} + (true, OnBusyUpdate::DoNothing) => {} } // Handle once option for integration testing