Fixes #272 missing md5sum

* dashboard: add warning if missing checksums
* add a "compute all missing md5sum" option in batch manager (inspired by delete orphans)
* progress bar when computing md5sums
This commit is contained in:
Teatek
2019-01-22 10:26:52 +01:00
committed by Pierrick Le Gall
parent 29f938acba
commit b05241f508
10 changed files with 206 additions and 4 deletions
+50
View File
@@ -2993,6 +2993,56 @@ SELECT CONCAT(
return $keys;
}
/**
* Return the list of image ids where md5sum is null
*
* @return int[] image_ids
*/
function get_photos_no_md5sum()
{
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
WHERE md5sum is null
;';
return query2array($query, null, 'id');
}
/**
* Compute and add the md5sum of image ids (where md5sum is null)
* @param int[] list of image ids and there paths
* @return int number of md5sum added
*/
function add_md5sum($ids)
{
$query = '
SELECT path
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(', ',$ids).')
;';
$paths = query2array($query, null, 'path');
$imgs_ids_paths = array_combine($ids, $paths);
$updates = array();
foreach ($ids as $id)
{
$file = PHPWG_ROOT_PATH.$imgs_ids_paths[$id];
$md5sum = md5_file($file);
$updates[] = array(
'id' => $id,
'md5sum' => $md5sum,
);
}
mass_updates(
IMAGES_TABLE,
array(
'primary' => array('id'),
'update' => array('md5sum')
),
$updates
);
return count($ids);
}
/**
* Return the list of image ids associated to no album
*