diff options
| author | ilotterytea <iltsu@alright.party> | 2025-06-17 22:30:05 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-06-17 22:30:05 +0500 |
| commit | 32471030d432eb8d3cef4af8bb00790f3b9f089c (patch) | |
| tree | 21ff3b736e55bbf196f4579f071a5e460c8edb35 /lib/file.php | |
| parent | 0a6f00749bb0720664409e9c4eca82928e6773c7 (diff) | |
feat: we are using SQL databases now
Diffstat (limited to 'lib/file.php')
| -rw-r--r-- | lib/file.php | 9 |
1 files changed, 6 insertions, 3 deletions
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; } |
