generated from jric11/baseProject
15 lines
635 B
PHP
15 lines
635 B
PHP
|
|
<?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);}
|
||
|
|
}
|
||
|
|
}
|