Files
huntingclubroster/classes/BackupValidation.php
T

15 lines
635 B
PHP
Raw Normal View History

<?php
final class BackupValidation {
/** mariadb-dump writes the completion comment at the end; never load the dump. */
public static function complete(string $path): bool {
clearstatcache(true,$path);
if(!is_file($path)||filesize($path)<100)return false;
$stream=fopen($path,'rb');if(!$stream)return false;
try{
if(fseek($stream,max(0,filesize($path)-8192),SEEK_SET)!==0)return false;
$tail=fread($stream,8192);
return $tail!==false&&preg_match('/(?:\A|\r?\n)-- Dump completed on [^\r\n]+(?:\r?\n)*\z/',$tail)===1;
}finally{fclose($stream);}
}
}