From 7aaabb2165a0393d06279c4d8c18ff70169dc220 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jan 2007 06:13:13 +0000 Subject: [PATCH] Minor code formatting tweaks. --- .../src/modules/storageServer/var/LocStor.php | 7 ++-- .../modules/storageServer/var/StoredFile.php | 36 ++++--------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/campcaster/src/modules/storageServer/var/LocStor.php b/campcaster/src/modules/storageServer/var/LocStor.php index fb6ad3242..39ff07d71 100644 --- a/campcaster/src/modules/storageServer/var/LocStor.php +++ b/campcaster/src/modules/storageServer/var/LocStor.php @@ -93,7 +93,7 @@ class LocStor extends BasicStor { if (PEAR::isError($oid)) { return $oid; } - $storedFile =& StoredFile::insert($oid, '', '', $metadata, + $storedFile =& StoredFile::Insert($oid, '', '', $metadata, 'string', $gunid, $ftype); if (PEAR::isError($storedFile)) { $res = BasicStor::RemoveObj($oid); @@ -606,10 +606,9 @@ class LocStor extends BasicStor { if (PEAR::isError($oid)) { return $oid; } - $storedFile =& StoredFile::insert($oid, '', '', + $storedFile =& StoredFile::Insert($oid, '', '', dirname(__FILE__).'/emptyPlaylist.xml', - 'file', $playlistId, 'playlist' - ); + 'file', $playlistId, 'playlist'); if (PEAR::isError($storedFile)) { $res = BasicStor::RemoveObj($oid); return $storedFile; diff --git a/campcaster/src/modules/storageServer/var/StoredFile.php b/campcaster/src/modules/storageServer/var/StoredFile.php index 2b1a6ff8e..3ecdee4d9 100644 --- a/campcaster/src/modules/storageServer/var/StoredFile.php +++ b/campcaster/src/modules/storageServer/var/StoredFile.php @@ -333,7 +333,7 @@ class StoredFile { $this->gunid = StoredFile::CreateGunid(); } $this->resDir = $this->_getResDir($this->gunid); - $this->filepath = $this->makeFileName(); + $this->filepath = "{$this->resDir}/{$this->gunid}"; $this->exists = is_file($this->filepath) && is_readable($this->filepath); $this->md = new MetaData($this->gunid, $this->resDir); } @@ -361,14 +361,12 @@ class StoredFile { * copy the media file if true, make symlink if false * @return StoredFile */ - public static function insert($oid, $filename, $localFilePath='', - $metadata='', $mdataLoc='file', $gunid=NULL, $ftype=NULL, $copyMedia=TRUE) + public static function Insert($oid, $filename, $localFilePath='', + $metadata='', $mdataLoc='file', $gunid=NULL, $ftype=NULL, + $copyMedia=TRUE) { global $CC_CONFIG, $CC_DBC; $storedFile = new StoredFile(($gunid ? $gunid : NULL)); - if (PEAR::isError($storedFile)) { - return $storedFile; - } $storedFile->name = $filename; $storedFile->id = $oid; $storedFile->mime = "unknown"; @@ -378,7 +376,6 @@ class StoredFile { } $storedFile->exists = FALSE; if (file_exists($localFilePath)) { - $storedFile->exists = TRUE; $md5 = md5_file($localFilePath); } $escapedName = pg_escape_string($filename); @@ -401,7 +398,7 @@ class StoredFile { $emptyState = FALSE; } if ( ($mdataLoc == 'file') && !file_exists($metadata)) { - return PEAR::raiseError("StoredFile::insert: ". + return PEAR::raiseError("StoredFile::Insert: ". "metadata file not found ($metadata)"); } $res = $storedFile->md->insert($metadata, $mdataLoc, $ftype); @@ -412,7 +409,7 @@ class StoredFile { // --- media file insert: if ($localFilePath != '') { if (!file_exists($localFilePath)) { - return PEAR::raiseError("StoredFile::insert: ". + return PEAR::raiseError("StoredFile::Insert: ". "media file not found ($localFilePath)"); } $res = $storedFile->addFile($localFilePath, $copyMedia); @@ -423,19 +420,11 @@ class StoredFile { $mime = $storedFile->getMime(); if ($mime !== FALSE) { $res = $storedFile->setMime($mime); - if (PEAR::isError($res)) { - $CC_DBC->query("ROLLBACK"); - return $res; - } } $emptyState = FALSE; } if (!$emptyState) { $res = $storedFile->setState('ready'); - if (PEAR::isError($res)) { - $CC_DBC->query("ROLLBACK"); - return $res; - } } $res = $CC_DBC->query("COMMIT"); if (PEAR::isError($res)) { @@ -676,17 +665,6 @@ class StoredFile { } - /** - * Contruct filepath of media file - * - * @return string - */ - public function makeFileName() - { - return "{$this->resDir}/{$this->gunid}"; - } - - /** * Create instance of StoredFile object and make copy of existing file * @@ -698,7 +676,7 @@ class StoredFile { */ public static function CopyOf(&$src, $nid) { - $storedFile = StoredFile::insert($nid, $src->name, $src->getRealFileName(), + $storedFile = StoredFile::Insert($nid, $src->name, $src->getRealFileName(), '', '', NULL, BasicStor::GetType($src->gunid)); if (PEAR::isError($storedFile)) { return $storedFile;