diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index ae923cee5..82e68aafd 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1170,10 +1170,7 @@ class StoredFile { return TRUE; } else { - return PEAR::raiseError( - "StoredFile::deleteFile: unlink failed ({$this->filepath})", - GBERR_FILEIO - ); + return PEAR::raiseError("StoredFile::deleteFile: unlink failed ({$this->filepath})"); } } else { @@ -1233,7 +1230,10 @@ class StoredFile { $files = StoredFile::getAll(); foreach ($files as $file) { $media = StoredFile::Recall($file["id"]); - $media->delete(); + $result = $media->delete(); + if (PEAR::isError($result)) { + return $result; + } } } diff --git a/utils/airtime-clean-storage.php b/utils/airtime-clean-storage.php index 516d7e73f..9424d35f3 100644 --- a/utils/airtime-clean-storage.php +++ b/utils/airtime-clean-storage.php @@ -60,7 +60,10 @@ function airtime_empty_db($db) Playlist::deleteAll(); echo " * Clearing files table...".PHP_EOL; - StoredFile::deleteAll(); + $result = StoredFile::deleteAll(); + if (PEAR::isError($result)) { + echo $result->getMessage().PHP_EOL; + } } @@ -89,6 +92,12 @@ if (isset($opts->h)) { exit; } +// Need to check that we are superuser before running this. +if (exec("whoami") != "root") { + echo PHP_EOL."You must be root to use this script.".PHP_EOL.PHP_EOL; + exit(1); +} + $CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE); $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);