Completed upgrade script for saving MD5 values for each file

This commit is contained in:
paul 2007-01-10 16:38:34 +00:00
parent 997814e78a
commit be48f1634f
1 changed files with 37 additions and 25 deletions

View File

@ -31,41 +31,53 @@ require_once("../installInit.php");
require_once("../../StoredFile.php"); require_once("../../StoredFile.php");
// Check to see if upgrade has already been applied // Check to see if upgrade has already been applied
//$sql = "SELECT md5 FROM ".$CC_CONFIG['filesTable']." LIMIT 1"; $sql = "SELECT md5 FROM ".$CC_CONFIG['filesTable']." LIMIT 1";
//$result = $CC_DBC->query($sql); $result = $CC_DBC->query($sql);
//if (!PEAR::isError($result)) { if (!PEAR::isError($result)) {
// echo "THIS UPGRADE HAS ALREADY BEEN APPLIED.\n"; echo "THIS UPGRADE HAS ALREADY BEEN APPLIED.\n";
// exit(0); exit(0);
//} }
//
//echo " * Modifying '".$CC_CONFIG['filesTable']." table..."; echo " * Adding column 'md5' to '".$CC_CONFIG['filesTable']." table...";
//$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ADD COLUMN md5 char(32)"; $sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ADD COLUMN md5 char(32)";
//camp_install_query($sql); camp_install_query($sql, false);
// $sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ALTER COLUMN md5 SET STORAGE EXTENDED";
//$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ALTER COLUMN md5 SET STORAGE EXTENDED"; camp_install_query($sql);
//camp_install_query($sql);
// echo " * Creating index on column 'md5'...";
//$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx ON ".$CC_CONFIG['filesTable']." (md5)"; $sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx ON ".$CC_CONFIG['filesTable']." (md5)";
//camp_install_query($sql); camp_install_query($sql);
// Get MD5 values for all files // Get MD5 values for all files
$sql = "SELECT gunid FROM ".$CC_CONFIG['filesTable'] ." WHERE ftype='audioclip'"; echo " * Computing MD5 sums for all files (this may take a while)...\n";
$sql = "SELECT to_hex(gunid) as gunid, name FROM ".$CC_CONFIG['filesTable'] ." WHERE ftype='audioclip'";
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
$errorFiles = array();
foreach ($rows as $row) { foreach ($rows as $row) {
echo $row['gunid']."\n"; $gunid = StoredFile::NormalizeGunid($row['gunid']);
$gunid = StoredFile::NormalizeGunid($gunid); $storedFile = new StoredFile($gunid);
$storedFile = new StoredFile($row['gunid']);
$fileName = $storedFile->getRealFileName(); $fileName = $storedFile->getRealFileName();
echo $fileName."\n"; $humanName = basename($row['name']);
echo " File: $humanName\n";
if (file_exists($fileName)) { if (file_exists($fileName)) {
$md5 = md5_file($fileName); $md5 = md5_file($fileName);
$storedFile->setMd5($md5); $storedFile->setMd5($md5);
//echo " MD5: $md5\n";
} else {
$errorFiles[] = "$gunid -- $humanName";
echo " ERROR: file does not exist! (GUNID: $gunid)\n";
} }
} }
if (count($errorFiles) > 0) {
echo "**********************************\n"; echo "\n\nWARNING\n";
echo "* StorageServer Install Complete *\n"; echo "The following files were not found:\n";
echo "**********************************\n"; foreach ($errorFiles as $file) {
echo $file."\n";
}
}
echo "*******************************************\n";
echo "* StorageServer Upgrade to 1.2.0 Complete *\n";
echo "*******************************************\n";
?> ?>