Implement Blake3 hashing in CDokumente; update related metadata and localization files

This commit is contained in:
2026-03-11 22:20:21 +01:00
parent e15dd14cab
commit 80dc3b40d3
9 changed files with 114 additions and 41 deletions

View File

@@ -35,22 +35,24 @@ class CDokumente extends \Espo\Core\Hooks\Base
return;
}
// Berechne neue Hashes
$newMd5 = hash_file('md5', $filePath);
$newSha256 = hash_file('sha256', $filePath);
// Berechne Blake3 Hash
$fileContent = file_get_contents($filePath);
if ($fileContent === false) {
return;
}
$newBlake3 = bin2hex(blake3($fileContent));
// Setze Hashes
$entity->set('md5sum', $newMd5);
$entity->set('sha256', $newSha256);
// Setze Hash
$entity->set('blake3hash', $newBlake3);
// Bestimme Status
if ($entity->isNew()) {
$entity->set('fileStatus', 'new');
} else {
$oldMd5 = $entity->getFetched('md5sum');
$oldSha256 = $entity->getFetched('sha256');
$oldBlake3 = $entity->getFetched('blake3hash');
if ($oldMd5 !== $newMd5 || $oldSha256 !== $newSha256) {
if ($oldBlake3 !== $newBlake3) {
$entity->set('fileStatus', 'changed');
} else {
$entity->set('fileStatus', 'synced');