This commit is contained in:
int2001
2025-10-03 18:35:16 +00:00
parent 7fa03f2035
commit 626175675f

View File

@@ -471,21 +471,36 @@ class Update extends CI_Controller {
/*
* Used for autoupdating the SOTA file which is used in the QSO entry dialog for autocompletion.
*/
public function update_sota() {
public function update_sota() {
$lockfilename='/tmp/.update_sota_running';
if (!file_exists($lockfilename)) {
touch($lockfilename);
$this->load->model('Update_model');
$result = $this->Update_model->sota();
if($this->session->userdata('user_type') == '99') {
if (substr($result, 0, 4) == 'DONE') {
$this->session->set_flashdata('success', __("SOTA Update complete. Result: ") . "'" . $result . "'");
} else {
$this->session->set_flashdata('error', __("SOTA Update failed. Result: ") . "'" . $result . "'");
$this->load->model('Update_model');
$result = $this->Update_model->sota();
unlink($lockfilename);
if($this->session->userdata('user_type') == '99') {
if (substr($result, 0, 4) == 'DONE') {
$this->session->set_flashdata('success', __("SOTA Update complete. Result: ") . "'" . $result . "'");
} else {
$this->session->set_flashdata('error', __("SOTA Update failed. Result: ") . "'" . $result . "'");
}
redirect('debug');
}
redirect('debug');
echo $result;
} 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';
}
}
}
}
/*
* Pulls the WWFF directory for autocompletion in QSO dialogs