Merge remote-tracking branch 'origin/develop' into feature/bildausschnitt
CI Feature / test (push) Successful in 7m24s
Deploy Test / test (push) Successful in 7m35s
Deploy Test / deploy (push) Successful in 44s

This commit is contained in:
Lars committed 2026-12-01 12:15:39 +01:00
commit 05dc1170aa
8 files changed
+293 -60

No files matched your search

+2 -1
View File
@@ -53,6 +53,7 @@ public function writeUnlessRecent(
string $action,
string $format,
string $marking,
string|\Closure|null $checksum = null,
): bool {
$recent = MediaDelivery::query()
->where('grant_id', $grant->id)
@@ -65,7 +66,7 @@ public function writeUnlessRecent(
return false;
}
$this->write($grant, $article, $release, $version, $action, $format, null, $marking);
$this->write($grant, $article, $release, $version, $action, $format, $checksum instanceof \Closure ? $checksum() : $checksum, $marking);
return true;
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace App\Domain\Media;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
/**
* SHA-256 einer Datei der Medienablage für den Auslieferungsnachweis (08 §7), je Datei einmal berechnet.
*
* Die Dateien sind nach dem Speichern unveränderlich. Der gemerkte Wert gilt daher für Pfad, Größe und Änderungszeit;
* ändert sich eine davon, wird neu gerechnet. Ist die Datei nicht lesbar, ist das Ergebnis null (der Nachweis nennt
* dann keine Prüfsumme, statt die Auslieferung zu blockieren).
*/
class FileChecksum
{
public function of(string $diskName, string $path): ?string
{
$disk = Storage::disk($diskName);
try {
if (! $disk->exists($path)) {
return null;
}
$key = 'media-checksum:'.hash('sha256', $diskName.'|'.$path.'|'.$disk->size($path).'|'.$disk->lastModified($path));
return Cache::rememberForever($key, function () use ($disk, $path): ?string {
$stream = $disk->readStream($path);
if (! is_resource($stream)) {
return null;
}
try {
$context = hash_init('sha256');
hash_update_stream($context, $stream);
return hash_final($context);
} finally {
fclose($stream);
}
});
} catch (\Throwable) {
return null;
}
}
}