From 2e59e069ec7abe9abec6c8f93c971830ed6e399a Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 3 Oct 2025 18:30:01 +0000 Subject: [PATCH] And for LOTW-Users --- application/controllers/Update.php | 45 +++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/application/controllers/Update.php b/application/controllers/Update.php index bc6e20bec..100007d3b 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -394,25 +394,44 @@ class Update extends CI_Controller { } - public function download_lotw_users() { - $this->lotw_users(); - } + public function download_lotw_users() { + $this->lotw_users(); + } - public function lotw_users() { + public function lotw_users() { + $lockfilename='/tmp/.update_lotw_users_running'; + if (!file_exists($lockfilename)) { + touch($lockfilename); - $this->load->model('Update_model'); - $result = $this->Update_model->lotw_users(); - if($this->session->userdata('user_type') == '99') { - if (substr($result, 0, 7) == 'Records') { - $this->session->set_flashdata('success', __("LoTW Users Update complete. Result: ") . "'" . $result . "'"); + + $this->load->model('Update_model'); + $result = $this->Update_model->lotw_users(); + unlink($lockfilename); + if($this->session->userdata('user_type') == '99') { + if (substr($result, 0, 7) == 'Records') { + $this->session->set_flashdata('success', __("LoTW Users Update complete. Result: ") . "'" . $result . "'"); + } else { + $this->session->set_flashdata('error', __("LoTW Users Update failed. Result: ") . "'" . $result . "'"); + } + redirect('debug'); } else { - $this->session->set_flashdata('error', __("LoTW Users 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'; + } } - } + + } /* * Used for autoupdating the DOK file which is used in the QSO entry dialog for autocompletion.