fix: prevent file deletion on relink + restore button now visible + OOB-style in-place update

Two critical fixes:

1. Relink flow no longer destroys/recreates FilePond instances:
   The relink (XamxamRelinkFile) and PeerTube relink (XamxamRelinkPeerTube)
   previously refreshed the entire fichiers fragment via HTMX after
   pond.addFile(). This triggered destroyFilePondsIn on ALL pools, which
   could fire server.remove callbacks and move existing files to corbeille.
   Now just closes the modal — the file is already added to the pool in-place,
   and syncOrderInput creates the hidden form input.

2. Cleanup page « Corbeille (restaurable) » now actually shows files:
   _cleanup-stats-data.php previously classified trash files by checking if
   the thesis_files DB row still existed. But both deleteThesisFileToTrash
   and FilepondHandler::handleRemove DELETE the DB row. So ALL trash files
   appeared as `stale` (not restorable). Now uses the JSON sidecar file
   presence as the classification criterion — if the sidecar exists and is
   recent, the file is restorable regardless of DB row state.

Also removed unused DB query from _cleanup-stats-data.php.
This commit is contained in:
Pontoporeia
2026-07-10 16:29:04 +02:00
parent ed19e30cf0
commit 3cecee10c9
12 changed files with 587 additions and 73 deletions
+19
View File
@@ -2565,6 +2565,25 @@ class Database
)->execute([$label ?: null, $fileId, $thesisId]);
}
/**
* Update an existing website-type thesis_files row in-place.
*
* Avoids the delete-then-insert pattern that loses the row ID and
* any associated metadata. Only updates the URL, derived filename,
* and optional display label.
*/
public function updateThesisWebsiteUrl(
int $fileId,
int $thesisId,
string $url,
string $fileName,
?string $label
): void {
$this->pdo->prepare(
'UPDATE thesis_files SET file_path = ?, file_name = ?, display_label = ? WHERE id = ? AND thesis_id = ?'
)->execute([$url, $fileName, $label ?: null, $fileId, $thesisId]);
}
/**
* Delete a single thesis file record by its ID and optionally remove the
* file from disk. Returns the file_path that was deleted (or null if not