function filehash_save in File Hash 7
Same name and namespace in other branches
- 8 filehash.module \filehash_save()
Calculates and saves the file hashes.
3 calls to filehash_save()
- filehash_file_insert in ./
filehash.module - Implements hook_file_insert().
- filehash_file_load in ./
filehash.module - Implements hook_file_load().
- filehash_file_update in ./
filehash.module - Implements hook_file_update().
File
- ./
filehash.module, line 183 - Generate hashes for each uploaded file.
Code
function filehash_save($file) {
$file->filehash = array_fill_keys(array(
'md5',
'sha1',
'sha256',
), NULL);
foreach (filehash_algos() as $algo) {
$file->filehash[$algo] = hash_file($algo, $file->uri);
}
db_merge('filehash')
->key(array(
'fid' => $file->fid,
))
->fields($file->filehash)
->execute();
}