I haven't found the root cause of these files becoming 0 bytes long, so I created a workaround to check the files and delete them if they are 0 bytes. This runs at the beginning of api.php.
The inserted code is as follows:
Code: Select all
function deletezerolengthfile ($filename) {
// 20250801 Steve Parry. Added to use in script to delete random zero lengtyh files caused by inderminate bugs.
if (file_exists($filename)) {
// File exists, now check its size
if (filesize($filename) == 0) {
unlink($filename); //delete the file
error_log ("[api.php] ".$filename . " Deleted due to zero length." . "\r\n");
}
}
}// end function
// 20250801 Steve Parry. Tidy up any of the files of zero length that can cause errors.
deletezerolengthfile ($base."meteotemplateLive.txt");
deletezerolengthfile ($base."update/realtime.txt");
deletezerolengthfile ($base."update/realtimegauges.txt");
deletezerolengthfile ($base."update/websitedata.json");
deletezerolengthfile ($base."update/wxnow.txt");
deletezerolengthfile ($base."cache/apiCache.txt");
deletezerolengthfile ($base."cache/apiLog.txt");
deletezerolengthfile ($base."cache/updateLog.txt");
deletezerolengthfile ($base."cache/apiCache.txt");
// End insertionCheers
...Steve
