public function detachFile($id)
{
/** @var File $file */
$file = File::findOne(['id' => $id]);
if (empty($file)) {
return false;
}
$filePath = $this->getFilesDirPath($file->hash) . DIRECTORY_SEPARATOR . $file->hash . '.' . $file->type;
// this is the important part of the override.
// the original methods doesn't check for file_exists to be
return file_exists($filePath) ? unlink($filePath) && $file->delete() : $file->delete();
}