public function delete($removeNode = true)
    {
        // first, we remove all files from the drive
        $db = Core::make(Connection::class);
        $em = $db->getEntityManager();
        $em->beginTransaction();
        try {
            // fire an on_page_delete event
            $fve = new \Concrete\Core\File\Event\DeleteFile($this);
            $fve = Events::dispatch('on_file_delete', $fve);
            if (!$fve->proceed()) {
                return false;
            }

            // Delete the tree node for the file.
            if ($removeNode) {
                $nodeID = $db->fetchColumn('select treeNodeID from TreeFileNodes where fID = ?', [$this->getFileID()]);
                if ($nodeID) {
                    $node = Node::getByID($nodeID);
                    $node->delete();
                }
            }

            $versions = $this->getVersionList();
            foreach ($versions as $fv) {
                $fv->delete(true);
            }

            $db->Execute('delete from FileSetFiles where fID = ?', [$this->fID]);
            $db->Execute('delete from FileSearchIndexAttributes where fID = ?', [$this->fID]);
            $db->Execute('delete from DownloadStatistics where fID = ?', [$this->fID]);
            $db->Execute('delete from FilePermissionAssignments where fID = ?', [$this->fID]);
            $db->Execute('delete from FileImageThumbnailPaths where fileID = ?', [$this->fID]);
            $db->Execute('delete from Files where fID = ?', [$this->fID]);

            $em->commit();
        } catch (\Exception $e) {
            $em->rollback();
            throw $e;
        }

        return true;
    }