fix: link old

This commit is contained in:
hashbro
2026-09-14 02:11:09 +08:00
parent d5ae0bf6ff
commit a360a7bc94
3 changed files with 59 additions and 8 deletions
@@ -178,8 +178,20 @@ class DeviceController extends Controller
$row = $device->photos()->whereKey($photo)->firstOrFail();
abort_unless($origin->ensureLocal($row), 404);
$abs = Storage::disk('local')->path($row->path);
$out = $preview->payload($abs, (string) $device->device_id, (string) ($row->sha256 ?: ''));
$abs = Storage::disk('local')->path((string) $row->path);
try {
$out = $preview->payload($abs, (string) $device->device_id, (string) ($row->sha256 ?: ''));
} catch (\Throwable $e) {
Log::warning('photo preview failed', [
'photo_id' => $row->id,
'path' => $row->path,
'error' => $e->getMessage(),
]);
abort(404);
}
if (($out['bytes'] ?? '') === '') {
abort(404);
}
if ((string) request()->query('seen', '') === '1') {
$this->markPhotoRead($row);
}