From 1febf11362bacdc2cea2a3f9c6c948a7e520a4bc Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Tue, 13 Oct 2020 16:41:43 +0200 Subject: [PATCH] FIX: Backup didn't work anymore after a running backup was canceled --- lib/backup_restore/backuper.rb | 2 ++ lib/backup_restore/system_interface.rb | 2 ++ spec/lib/backup_restore/system_interface_spec.rb | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/lib/backup_restore/backuper.rb b/lib/backup_restore/backuper.rb index 8f000908877..dea11cda147 100644 --- a/lib/backup_restore/backuper.rb +++ b/lib/backup_restore/backuper.rb @@ -96,6 +96,8 @@ module BackupRestore end def listen_for_shutdown_signal + BackupRestore.clear_shutdown_signal! + Thread.new do while BackupRestore.is_operation_running? exit if BackupRestore.should_shutdown? diff --git a/lib/backup_restore/system_interface.rb b/lib/backup_restore/system_interface.rb index 2ed95137bc8..fec67354178 100644 --- a/lib/backup_restore/system_interface.rb +++ b/lib/backup_restore/system_interface.rb @@ -44,6 +44,8 @@ module BackupRestore end def listen_for_shutdown_signal + BackupRestore.clear_shutdown_signal! + Thread.new do while BackupRestore.is_operation_running? exit if BackupRestore.should_shutdown? diff --git a/spec/lib/backup_restore/system_interface_spec.rb b/spec/lib/backup_restore/system_interface_spec.rb index a2a2c4314ee..d75de32dc8c 100644 --- a/spec/lib/backup_restore/system_interface_spec.rb +++ b/spec/lib/backup_restore/system_interface_spec.rb @@ -69,6 +69,15 @@ describe BackupRestore::SystemInterface do thread.join end.to raise_error(SystemExit) end + + it "clears an existing shutdown signal before it starts to listen" do + BackupRestore.set_shutdown_signal! + expect(BackupRestore.should_shutdown?).to eq(true) + + thread = subject.listen_for_shutdown_signal + expect(BackupRestore.should_shutdown?).to eq(false) + Thread.kill(thread) + end end describe "#pause_sidekiq" do