mirror of
https://github.com/unraid/webgui.git
synced 2026-05-03 08:19:27 -05:00
Parity log optimization
This commit is contained in:
@@ -198,9 +198,21 @@ function compress($name,$size=18,$end=6) {
|
||||
function escapestring($name) {
|
||||
return "\"$name\"";
|
||||
}
|
||||
function tail($file, $rows=1) {
|
||||
$file = new SplFileObject($file);
|
||||
$file->seek(SEEK_END);
|
||||
$end = $file->key();
|
||||
$file->seek($end-$rows);
|
||||
$echo = [];
|
||||
while (!$file->eof()) {
|
||||
$echo[] = $file->current();
|
||||
$file->next();
|
||||
}
|
||||
return implode($echo);
|
||||
}
|
||||
function last_parity_log() {
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
[$date,$duration,$speed,$status,$error,$action,$size] = file_exists($log) ? my_explode('|',exec("tail -1 $log"),7) : array_fill(0,7,0);
|
||||
[$date,$duration,$speed,$status,$error,$action,$size] = file_exists($log) ? my_explode('|',tail($log),7) : array_fill(0,7,0);
|
||||
if ($date) {
|
||||
[$y,$m,$d,$t] = my_preg_split('/ +/',$date,4);
|
||||
$date = strtotime("$d-$m-$y $t");
|
||||
|
||||
@@ -37,7 +37,7 @@ session_destroy();
|
||||
|
||||
function new_parity_log($timestamp) {
|
||||
global $log;
|
||||
return file_exists($log) ? explode('|',exec("tail -1 $log"))[0]!=$timestamp : true;
|
||||
return file_exists($log) ? explode('|',tail($log))[0]!=$timestamp : true;
|
||||
}
|
||||
function my_clock($time) {
|
||||
if (!$time) return _('less than a minute');
|
||||
|
||||
Reference in New Issue
Block a user