Head-scratcher for me.
Have a cron job which renames files.
Goes along for hours just fine, then loses it.
No error reporting, no problems, just carries on as if the results from rename() and files_exists() were true.
Suspect maybe some conflict? Not sure how to proceed with locking to ensure exclusive access.
// Holy heck here. Not trusting result from rename
$result = @rename($oldfn,$newfn);
$result=@file_exists($newfn);
if ( $result == true)
{
$q="UPDATE vb_man_video_images SET vidRenamed='$vid[seed]' WHERE imageid='$vid[imageid]'";
$DB_site->query($q);
$flag=" ";
}
else
{
$dtRenamed=date($dtFormatEx,$vid['vidRenamed']);
$dtLastdownloaded=date($dtFormatEx,$vid['vidLastdownloaded']);
$flag="***";
$countErrors++;
}
I end up with no errors reported, but the file mwas not renamed. Meantime, the database is updated with the new name that no longer matches the file system.
Arrghh.... Looked around this forum but people seem to be using these functions without issue. There must be another element I am unaware of.
Is there an approach to "bullet proof" this task?
Many thanks in advance.