From d3819766338b445ecef1b636f01423c72f8c0789 Mon Sep 17 00:00:00 2001 From: tomash Date: Wed, 22 Mar 2006 15:20:27 +0000 Subject: [PATCH] #1604 some exceptions catching added --- .../modules/storageServer/var/BasicStor.php | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/livesupport/src/modules/storageServer/var/BasicStor.php b/livesupport/src/modules/storageServer/var/BasicStor.php index 50da05156..9138fd04d 100644 --- a/livesupport/src/modules/storageServer/var/BasicStor.php +++ b/livesupport/src/modules/storageServer/var/BasicStor.php @@ -982,22 +982,24 @@ class BasicStor extends Alib{ $res = `cd $tmpd; tar xf $fname`; // clips: $d = dir($tmpdc); $entries=array(); $gunids=array(); - while (false !== ($entry = $d->read())) { - if(preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)){ - list(,$gunid, $ext) = $va; - switch($ext){ - case"xml": - $entries[$gunid]['metadata'] = $entry; - break; - default: - $entries[$gunid]['rawMedia'] = $entry; - $entries[$gunid]['rawMediaExt'] = $ext; - $gunids[$entry] = $gunid; - break; + if($d !== false){ + while (false !== ($entry = $d->read())) { + if(preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)){ + list(,$gunid, $ext) = $va; + switch($ext){ + case"xml": + $entries[$gunid]['metadata'] = $entry; + break; + default: + $entries[$gunid]['rawMedia'] = $entry; + $entries[$gunid]['rawMediaExt'] = $ext; + $gunids[$entry] = $gunid; + break; + } } } + $d->close(); } - $d->close(); $res = TRUE; foreach($entries as $gunid=>$it){ $rawMedia = "$tmpdc/{$it['rawMedia']}"; @@ -1014,19 +1016,21 @@ class BasicStor extends Alib{ // playlists: require_once"Playlist.php"; $d = dir($tmpdp); - while ((!PEAR::isError($res)) && false !== ($entry = $d->read())) { - if(preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)){ - list(,$gunid, $ext) = $va; - $res = $this->bsImportPlaylistRaw($parid, $gunid, - $tmpdp, $entry, $ext, $gunids, $subjid); - unlink("$tmpdp/$entry"); - if(PEAR::isError($res)) break; - } + if($d !== false){ + while ((!PEAR::isError($res)) && false !== ($entry = $d->read())) { + if(preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)){ + list(,$gunid, $ext) = $va; + $res = $this->bsImportPlaylistRaw($parid, $gunid, + $tmpdp, $entry, $ext, $gunids, $subjid); + unlink("$tmpdp/$entry"); + if(PEAR::isError($res)) break; + } + } + $d->close(); } - $d->close(); //@rmdir($tmpdc); @rmdir($tmpdp); @rmdir($tmpd); - system("rm -rf $tmpdc"); system("rm -rf $tmpdp"); system("rm -rf $tmpd"); - unlink($tmpn); + @system("rm -rf $tmpdc"); @system("rm -rf $tmpdp"); @system("rm -rf $tmpd"); + @unlink($tmpn); return $res; }