From 7e904aec06c09f7fdef0938155d2b9a19d36e314 Mon Sep 17 00:00:00 2001 From: Agando Date: Sun, 18 Oct 2026 17:19:14 +0200 Subject: newOS4 v4.6.40: review fixes (bug diagnostics, trash tree, dir paste, stale capture, preview) --- api/debug/report.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'api/debug/report.php') diff --git a/api/debug/report.php b/api/debug/report.php index a4cf9f1..cefcae6 100644 --- a/api/debug/report.php +++ b/api/debug/report.php @@ -61,6 +61,13 @@ foreach (array_slice(array_reverse($existing), 0, 100) as $f) { $d = json_decode(@file_get_contents($f), true); if (!is_array($d)) continue; if (($d['fingerprint'] ?? '') === $fingerprint && strtotime($d['created_at'] ?? '') > $now - 86400) { + // Don't discard user content on a duplicate: keep it as an appended note. + $d['duplicate_count'] = (int)($d['duplicate_count'] ?? 0) + 1; + if ($body !== '' && ($d['body'] ?? '') !== $body) { + $d['body'] = trim((string)($d['body'] ?? '') . "\n---\n[duplicate " . gmdate('c') . "] " . $body); + $json = json_encode($d, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + if ($json !== false) { @file_put_contents($f, $json); @chmod($f, 0664); } + } json_response([ 'success' => true, 'id' => $d['id'], @@ -91,6 +98,12 @@ if ($json === false || file_put_contents($file, $json) === false) { } @chmod($file, 0664); +// Regenerate the public page immediately so the URL we print is never stale. +$generator = realpath(__DIR__ . '/../../scripts/gen-bug-report.py'); +if ($generator) { + @exec('/usr/bin/python3 ' . escapeshellarg($generator) . ' 2>&1', $genOut, $genRc); +} + json_response([ 'success' => true, 'id' => $id, -- cgit v1.2.3