NEW The integrity checker now show the expected size of files

This commit is contained in:
Laurent Destailleur 2019-11-04 13:23:48 +01:00
parent d934f5e920
commit 8aa2fd04ad
6 changed files with 20 additions and 7 deletions

View File

@ -164,7 +164,7 @@ foreach ($files as $filetmp) {
if (filetype($file)=="file") {
$md5=md5_file($file);
$checksumconcat[]=$md5;
fputs($fp, ' <md5file name="'.basename($file).'">'.$md5.'</md5file>'."\n");
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
}
}
fputs($fp, ' </dir>'."\n");
@ -207,7 +207,7 @@ foreach ($files as $filetmp) {
if (filetype($file)=="file") {
$md5=md5_file($file);
$checksumconcat[]=$md5;
fputs($fp, ' <md5file name="'.basename($file).'">'.$md5.'</md5file>'."\n");
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
}
}
fputs($fp, ' </dir>'."\n");

View File

@ -239,6 +239,7 @@ if (! $error && $xml)
$out.='<tr class="liste_titre">';
$out.='<td>#</td>';
$out.='<td>' . $langs->trans("Filename") . '</td>';
$out.='<td class="right">' . $langs->trans("ExpectedSize") . '</td>';
$out.='<td class="center">' . $langs->trans("ExpectedChecksum") . '</td>';
$out.='</tr>'."\n";
$tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
@ -251,6 +252,9 @@ if (! $error && $xml)
$out.='<tr class="oddeven">';
$out.='<td>'.$i.'</td>' . "\n";
$out.='<td>'.$file['filename'].'</td>' . "\n";
$out.='<td class="right">';
if (! empty($file['expectedsize'])) $out.=dol_print_size($file['expectedsize']);
$out.='</td>' . "\n";
$out.='<td class="center">'.$file['expectedmd5'].'</td>' . "\n";
$out.="</tr>\n";
}
@ -275,7 +279,8 @@ if (! $error && $xml)
$out.='<td>' . $langs->trans("Filename") . '</td>';
$out.='<td class="center">' . $langs->trans("ExpectedChecksum") . '</td>';
$out.='<td class="center">' . $langs->trans("CurrentChecksum") . '</td>';
$out.='<td class="right">' . $langs->trans("Size") . '</td>';
$out.='<td class="right">' . $langs->trans("ExpectedSize") . '</td>';
$out.='<td class="right">' . $langs->trans("CurrentSize") . '</td>';
$out.='<td class="right">' . $langs->trans("DateModification") . '</td>';
$out.='</tr>'."\n";
$tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
@ -290,6 +295,9 @@ if (! $error && $xml)
$out.='<td>'.$file['filename'].'</td>' . "\n";
$out.='<td class="center">'.$file['expectedmd5'].'</td>' . "\n";
$out.='<td class="center">'.$file['md5'].'</td>' . "\n";
$out.='<td class="right">';
if ($file['expectedsize']) $out.=dol_print_size($file['expectedsize']);
$out.='</td>' . "\n";
$size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']);
$totalsize += $size;
$out.='<td class="right">'.dol_print_size($size).'</td>' . "\n";
@ -301,6 +309,7 @@ if (! $error && $xml)
$out.='<td>'.$langs->trans("Total").'</td>' . "\n";
$out.='<td class="center"></td>' . "\n";
$out.='<td class="center"></td>' . "\n";
$out.='<td class="center"></td>' . "\n";
$out.='<td class="right">'.dol_print_size($totalsize).'</td>' . "\n";
$out.='<td class="right"></td>' . "\n";
$out.="</tr>\n";

View File

@ -3072,13 +3072,14 @@ function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '', $pathre
{
$filename = $path.$file['name'];
$file_list['insignature'][] = $filename;
$expectedsize = (empty($file['size']) ? '' : $file['size']);
$expectedmd5 = (string) $file;
//if (preg_match('#'.$exclude.'#', $filename)) continue;
if (!file_exists($pathref.'/'.$filename))
{
$file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5);
$file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'expectedsize'=>$expectedsize);
}
else
{
@ -3090,7 +3091,7 @@ function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '', $pathre
}
else
{
if ($md5_local != $expectedmd5) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local);
if ($md5_local != $expectedmd5) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'expectedsize'=>$expectedsize, 'md5'=>(string) $md5_local);
$checksumconcat[] = $md5_local;
}
}

View File

@ -1796,6 +1796,8 @@ FixTZ=TimeZone fix
FillFixTZOnlyIfRequired=Example: +2 (fill only if problem experienced)
ExpectedChecksum=Expected Checksum
CurrentChecksum=Current Checksum
ExpectedSize=Expected size
CurrentSize=Current size
ForcedConstants=Required constant values
MailToSendProposal=Customer proposals
MailToSendOrder=Sales orders

View File

@ -181,13 +181,13 @@ class Ticket extends CommonObject
'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''),
'track_id' => array('type'=>'varchar(255)', 'label'=>'TicketTrackId', 'visible'=>-2, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"),
'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'nowraponall'),
'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'),
'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"),
'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth75'),
'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'),
'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketGroup', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'),
'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'),
'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"),
'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""),

View File

@ -3,6 +3,7 @@
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by