kopia lustrzana https://github.com/magicbug/Cloudlog
Improve update status handling and error reporting
Added get_status endpoint to Update controller for serving update status. Enhanced update_status to handle directory creation and log errors. Updated footer view to use new endpoint, improved error handling and retry logic for status updates.pull/3318/head
rodzic
046dc4b4ef
commit
66d6fc91a8
|
@ -219,6 +219,16 @@ class Update extends CI_Controller {
|
|||
$this->update_status("DONE");
|
||||
}
|
||||
|
||||
public function get_status() {
|
||||
$status_file = $this->make_update_path("status.html");
|
||||
if (file_exists($status_file)) {
|
||||
$content = file_get_contents($status_file);
|
||||
echo $content;
|
||||
} else {
|
||||
echo "No status available";
|
||||
}
|
||||
}
|
||||
|
||||
public function update_status($done=""){
|
||||
|
||||
if ($done != "Downloading file"){
|
||||
|
@ -234,7 +244,16 @@ class Update extends CI_Controller {
|
|||
$html = $done."....<br/>";
|
||||
}
|
||||
|
||||
file_put_contents($this->make_update_path("status.html"), $html);
|
||||
$status_file = $this->make_update_path("status.html");
|
||||
if (file_put_contents($status_file, $html) === FALSE) {
|
||||
log_message('error', 'Failed to write status file: ' . $status_file);
|
||||
// Try to create the directory if it doesn't exist
|
||||
$dir = dirname($status_file);
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
file_put_contents($status_file, $html);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1935,12 +1935,16 @@ if ($this->session->userdata('user_id') != null) {
|
|||
});
|
||||
|
||||
function update_stats() {
|
||||
$('#dxcc_update_status').load('<?php echo base_url() ?>updates/status.html', function(val) {
|
||||
$('#dxcc_update_staus').html(val);
|
||||
$('#dxcc_update_status').load('<?php echo base_url() ?>index.php/update/get_status', function(val) {
|
||||
$('#dxcc_update_status').html(val);
|
||||
|
||||
if ((val === null) || (val.substring(0, 4) != "DONE")) {
|
||||
if ((val === null) || (val === undefined) || (typeof val !== 'string') || (val.substring(0, 4) !== "DONE")) {
|
||||
setTimeout(update_stats, 5000);
|
||||
}
|
||||
}).fail(function(xhr, status, error) {
|
||||
console.log('Error loading status: ' + status + ' - ' + error);
|
||||
$('#dxcc_update_status').html('Error loading status...');
|
||||
setTimeout(update_stats, 10000); // Retry in 10 seconds on error
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue