From 705bd34c333c334f47601601a89e35ed2e925143 Mon Sep 17 00:00:00 2001 From: tomas Date: Wed, 8 Dec 2004 01:47:18 +0000 Subject: [PATCH] Minor changes in LocStor::storeAudioClip and StoredFile::insert (bug. 483) --- .../modules/storageServer/var/LocStor.php | 12 +++++++++-- .../modules/storageServer/var/StoredFile.php | 20 +++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/livesupport/modules/storageServer/var/LocStor.php b/livesupport/modules/storageServer/var/LocStor.php index d117b0f92..9db68419e 100644 --- a/livesupport/modules/storageServer/var/LocStor.php +++ b/livesupport/modules/storageServer/var/LocStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $ ------------------------------------------------------------------------------*/ @@ -102,7 +102,10 @@ class LocStor extends GreenBox{ $ac =& StoredFile::insert( &$this, $oid, '', $mediaFileLP, $mdataFileLP, $gunid ); - if(PEAR::isError($ac)) return $ac; + if(PEAR::isError($ac)){ + $res = $this->removeObj($oid); + return $ac; + } $res = $this->renameFile($oid, $ac->gunid, $sessid); if(PEAR::isError($res)) return $res; } @@ -121,6 +124,11 @@ class LocStor extends GreenBox{ if(PEAR::isError($ac)) return $ac; if(($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) return $res; + if($ac->isAccessed()){ + return PEAR::raiseError( + 'LocStor.php: deleteAudioClip: is accessed' + ); + } $res = $this->deleteFile($ac->getId(), $sessid); if(PEAR::isError($res)) return $res; return TRUE; diff --git a/livesupport/modules/storageServer/var/StoredFile.php b/livesupport/modules/storageServer/var/StoredFile.php index c290b1d3f..50f56dad1 100644 --- a/livesupport/modules/storageServer/var/StoredFile.php +++ b/livesupport/modules/storageServer/var/StoredFile.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $ ------------------------------------------------------------------------------*/ @@ -80,7 +80,8 @@ class StoredFile{ * @param gunid global unique id (optional) - for insert file with gunid * @return instace of StoredFile object */ - function insert(&$gb, $oid, $name, $mediaFileLP='', $mdataFileLP='', $gunid=NULL) + function insert(&$gb, $oid, $name, + $mediaFileLP='', $mdataFileLP='', $gunid=NULL) { $ac =& new StoredFile(&$gb, ($gunid ? $gunid : NULL)); $ac->name = $name; @@ -94,20 +95,31 @@ class StoredFile{ ('$oid', '{$ac->name}', '{$ac->gunid}', '{$ac->type}')" ); if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; } + // --- metadata insert: if($mdataFileLP != ''){ + if(!file_exists($mdataFileLP)) + { + return PEAR::raiseError("StoredFile::insert: ". + "metadata file doesn't exists ($mdataFileLP)"); + } $res = $ac->md->insert($mdataFileLP); if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; } } + // --- media file insert: if($mediaFileLP != ''){ + if(!file_exists($mediaFileLP)) + { + return PEAR::raiseError("StoredFile::insert: ". + "media file doesn't exists ($mediaFileLP)"); + } $res = $ac->rmd->insert($mediaFileLP); if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; } $mime = $ac->rmd->getMime(); -// return PEAR::raiseError("X1"); -// $gb->debugLog("gunid={$ac->gunid}, mime=$mime"); + //$gb->debugLog("gunid={$ac->gunid}, mime=$mime"); if($mime !== FALSE){ $res = $ac->dbc->query("UPDATE {$ac->filesTable} SET type='$mime' WHERE id='$oid'");