[Avatar] Implement avatar deletion

This commit is contained in:
2021-04-29 18:12:32 +00:00
parent 2ec7059076
commit e9b2b18093
4 changed files with 78 additions and 45 deletions

View File

@@ -171,12 +171,20 @@ class AttachmentThumbnail extends Entity
}
/**
* Delete a attachment thumbnail. This table doesn't own all the attachments, only itself
* Delete an attachment thumbnail
*/
public function delete(bool $flush = false, bool $delete_attachments_now = false, bool $cascading = false): string
public function delete(bool $flush = true): void
{
// TODO Implement deleting attachment thumbnails
return '';
$filepath = $this->getPath();
if (file_exists($filepath)) {
if (@unlink($filepath) === false) {
Log::warning("Failed deleting file for attachment thumbnail with id={$this->attachment_id}, width={$this->width}, height={$this->height} at {$filepath}");
}
}
DB::remove($this);
if ($flush) {
DB::flush();
}
}
public static function schemaDef(): array