From 32471030d432eb8d3cef4af8bb00790f3b9f089c Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 17 Jun 2025 22:30:05 +0500 Subject: feat: we are using SQL databases now --- lib/file.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/file.php') diff --git a/lib/file.php b/lib/file.php index fe7dae1..fc3e38a 100644 --- a/lib/file.php +++ b/lib/file.php @@ -19,12 +19,11 @@ function verify_mimetype(string $file_path, string $mimetype): bool throw new RuntimeException("Illegal type for MIME verifications: $mimetype"); } -function delete_file(string $file_id, string $file_extension): bool +function delete_file(string $file_id, string $file_extension, PDO|null $db = null): bool { $paths = [ FILE_UPLOAD_DIRECTORY . "/{$file_id}.{$file_extension}", - FILE_THUMBNAIL_DIRECTORY . "/{$file_id}.webp", - FILE_METADATA_DIRECTORY . "/{$file_id}.metadata.json" + FILE_THUMBNAIL_DIRECTORY . "/{$file_id}.webp" ]; foreach ($paths as $path) { @@ -33,6 +32,10 @@ function delete_file(string $file_id, string $file_extension): bool } } + if ($db) { + $db->prepare('DELETE FROM files WHERE id = ? AND extension = ?')->execute([$file_id, $file_extension]); + } + return true; } -- cgit v1.2.3