[FEATURE] option to randomize file hash

By configuring `file_hash` option to `random`, file deduplication is not
effective anymore but file is not hashed.

Signed-off-by: Jerome Jutteau <jerome@jutteau.fr>
This commit is contained in:
Jerome Jutteau 2019-12-17 18:51:29 +01:00
parent 4fd0b80934
commit c793d07489
2 changed files with 5 additions and 2 deletions

View File

@ -152,7 +152,8 @@ $cfg['proxy_ip'] = array();
* By default, files are hashed through md5 but other methods are available.
* Possible values are 'md5' and 'md5_outside'.
* With 'md5' option, the whole file is hashed through md5. This is the default.
* With 'md5_outside', md5 is used to hash the first part of the file, the last part of the file
* With 'md5_outside', md5 is used to hash the first part of the file, the last part of the file.
* With 'random', file hash not set to a random value and file deduplication cannot work anymore but it is fast and safe.
* and the file's size. This method is fast for large files but cannot be perfect.
*/
$cfg['file_hash'] = 'md5';

View File

@ -321,7 +321,7 @@ function jirafeau_delete_file($hash)
/** hash file's content
* @param $method hash method, see 'file_hash' option. 'md5' or 'md5_outside'.
* @param $method hash method, see 'file_hash' option. Valid methods are 'md5', 'md5_outside' or 'random'
* @param $file_path file to hash
* @returns hash string
*/
@ -332,6 +332,8 @@ function jirafeau_hash_file($method, $file_path)
return jirafeau_md5_outside($file_path);
case 'md5':
return md5_file($file_path);
case 'random':
return jirafeau_gen_random(32);
}
return md5_file($file_path);
}