From 84acd82fc3f7fa93d86bbacc463c5c0a4306db80 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 3 Oct 2025 18:40:39 +0000 Subject: [PATCH] TLE --- application/controllers/Update.php | 36 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 554188a72..dd7772cc4 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -609,20 +609,36 @@ class Update extends CI_Controller { } } - public function update_tle($returnpath = 'debug') { - $this->load->model('Update_model'); - $result = $this->Update_model->tle(); - if($this->session->userdata('user_type') == '99') { - if (substr($result, 0, 4) == 'This') { - $this->session->set_flashdata('success', __("TLE Update complete. Result: ") . "'" . $result . "'"); + public function update_tle($returnpath = 'debug') { + $lockfilename='/tmp/.update_tle_running'; + if (!file_exists($lockfilename)) { + touch($lockfilename); + $this->load->model('Update_model'); + $result = $this->Update_model->tle(); + unlink($lockfilename); + if($this->session->userdata('user_type') == '99') { + if (substr($result, 0, 4) == 'This') { + $this->session->set_flashdata('success', __("TLE Update complete. Result: ") . "'" . $result . "'"); + } else { + $this->session->set_flashdata('error', __("TLE Update failed. Result: ") . "'" . $result . "'"); + } + redirect($returnpath); } else { - $this->session->set_flashdata('error', __("TLE Update failed. Result: ") . "'" . $result . "'"); + echo $result; } - redirect($returnpath); } 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 update_lotw_sats() { $this->load->model('Update_model');