From 42713e9ad24e3596869f6ac367d468e556cb3ca6 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 3 Oct 2025 18:26:57 +0000 Subject: [PATCH] Same for Updating SCP from Clublog --- application/controllers/Update.php | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 7ccd02f95..bc6e20bec 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -360,21 +360,39 @@ class Update extends CI_Controller { $this->logbook_model->check_missing_grid_id($all); } - public function update_clublog_scp() { + public function update_clublog_scp() { + $lockfilename='/tmp/.update_clublog_scp_running'; + if (!file_exists($lockfilename)) { + touch($lockfilename); - $this->load->model('Update_model'); - $result = $this->Update_model->clublog_scp(); - if($this->session->userdata('user_type') == '99') { - if (substr($result, 0, 4) == 'DONE') { - $this->session->set_flashdata('success', __("SCP Update complete. Result: ") . "'" . $result . "'"); + $this->load->model('Update_model'); + $result = $this->Update_model->clublog_scp(); + unlink($lockfilename); + if($this->session->userdata('user_type') == '99') { + if (substr($result, 0, 4) == 'DONE') { + $this->session->set_flashdata('success', __("SCP Update complete. Result: ") . "'" . $result . "'"); + } else { + $this->session->set_flashdata('error', __("SCP Update failed. Result: ") . "'" . $result . "'"); + } + redirect('debug'); } else { - $this->session->set_flashdata('error', __("SCP Update failed. Result: ") . "'" . $result . "'"); + echo $result; } - redirect('debug'); } else { - echo $result; + log_message('debug', 'There is a lockfile for this job. Checking the age...'); + $lockfile_time = filemtime($lockfilename); + $tdiff = time() - $lockfile_time; + if ($tdiff > 120) { + + unlink($lockfilename); + log_message('debug', 'Deleted lockfile because it was older then 120seconds.'); + } else { + log_message('debug', 'Process is currently locked. Further calls are ignored.'); + echo 'locked - running'; + } } - } + + } public function download_lotw_users() { $this->lotw_users();