Code formatting

This commit is contained in:
paul 2006-12-08 04:33:35 +00:00
parent 55688910d5
commit f98af0ace0

View file

@ -307,89 +307,92 @@ class Transport
*/ */
function upload2Hub($gunid, $withContent=TRUE, $pars=array()) function upload2Hub($gunid, $withContent=TRUE, $pars=array())
{ {
$this->trLog("upload2Hub start: ".strftime("%H:%M:%S"));
switch ($ftype = $this->gb->_getType($gunid)) { switch ($ftype = $this->gb->_getType($gunid)) {
case "audioclip": case "audioclip":
case "webstream": case "webstream":
$ac = StoredFile::recallByGunid($this->gb, $gunid); $ac = StoredFile::recallByGunid($this->gb, $gunid);
if (PEAR::isError($ac)) { if (PEAR::isError($ac)) {
return $ac; return $ac;
}
// handle metadata:
$mdfpath = $ac->_getRealMDFname();
if (PEAR::isError($mdfpath)) {
return $mdfpath;
}
$mdtrec = $this->_uploadGeneralFileToHub($mdfpath, 'metadata',
array_merge(array('gunid'=>$gunid, 'fname'=>'metadata',), $pars)
);
if (PEAR::isError($mdtrec)) {
return $mdtrec;
}
// handle raw media file:
$fpath = $ac->_getRealRADFname();
if (PEAR::isError($fpath)) {
return $fpath;
}
$fname = $ac->_getFileName();
if (PEAR::isError($fname)) {
return $fname;
}
$trec = $this->_uploadGeneralFileToHub($fpath, 'audioclip',
array_merge(array(
'gunid'=>$gunid, 'fname'=>$fname, 'mdtrtok'=>$mdtrec->trtok,
), $pars)
);
if (PEAR::isError($trec)) {
return $trec;
}
$this->startCronJobProcess($mdtrec->trtok);
break;
case "playlist":
$plid = $gunid;
require_once("Playlist.php");
$pl = Playlist::recallByGunid($this->gb, $plid);
if (PEAR::isError($pl)) {
return $pl;
}
$fname = $pl->_getFileName();
if (PEAR::isError($fname)) {
return $fname;
}
if ($withContent) {
$res = $this->gb->bsExportPlaylistOpen($plid);
if (PEAR::isError($res)) {
return $res;
} }
$tmpn = tempnam($this->transDir, 'plExport_'); // handle metadata:
$plfpath = "$tmpn.lspl"; $mdfpath = $ac->_getRealMDFname();
copy($res['fname'], $plfpath); if (PEAR::isError($mdfpath)) {
$res = $this->gb->bsExportPlaylistClose($res['token']); return $mdfpath;
if (PEAR::isError($res)) {
return $res;
} }
$fname = $fname.".lspl"; $mdtrec = $this->_uploadGeneralFileToHub($mdfpath, 'metadata',
$trtype = 'playlistPkg'; array_merge(array('gunid'=>$gunid, 'fname'=>'metadata',), $pars)
} else { );
$plfpath = $pl->_getRealMDFname(); if (PEAR::isError($mdtrec)) {
if (PEAR::isError($plfpath)) { return $mdtrec;
return $plfpath;
} }
$trtype = 'playlist'; // handle raw media file:
} $fpath = $ac->_getRealRADFname();
$trec = $this->_uploadGeneralFileToHub($plfpath, $trtype, if (PEAR::isError($fpath)) {
array_merge(array('gunid'=>$plid,'fname'=>$fname,), $pars) return $fpath;
); }
if (PEAR::isError($trec)) { $fname = $ac->_getFileName();
return $trec; if (PEAR::isError($fname)) {
} return $fname;
break; }
default: $trec = $this->_uploadGeneralFileToHub($fpath, 'audioclip',
return PEAR::raiseError( array_merge(array(
"Transport::upload2Hub:". 'gunid'=>$gunid, 'fname'=>$fname, 'mdtrtok'=>$mdtrec->trtok,
" ftype not supported ($ftype)" ), $pars)
); );
if (PEAR::isError($trec)) {
return $trec;
}
$this->startCronJobProcess($mdtrec->trtok);
break;
case "playlist":
$plid = $gunid;
require_once("Playlist.php");
$pl = Playlist::recallByGunid($this->gb, $plid);
if (PEAR::isError($pl)) {
return $pl;
}
$fname = $pl->_getFileName();
if (PEAR::isError($fname)) {
return $fname;
}
if ($withContent) {
$this->trLog("upload2Hub exportPlaylistOpen BEGIN: ".strftime("%H:%M:%S"));
$res = $this->gb->bsExportPlaylistOpen($plid);
$this->trLog("upload2Hub exportPlaylistOpen END: ".strftime("%H:%M:%S"));
if (PEAR::isError($res)) {
return $res;
}
$tmpn = tempnam($this->transDir, 'plExport_');
$plfpath = "$tmpn.lspl";
$this->trLog("upload2Hub begin copy: ".strftime("%H:%M:%S"));
copy($res['fname'], $plfpath);
$this->trLog("upload2Hub end copy: ".strftime("%H:%M:%S"));
$res = $this->gb->bsExportPlaylistClose($res['token']);
if (PEAR::isError($res)) {
return $res;
}
$fname = $fname.".lspl";
$trtype = 'playlistPkg';
} else {
$plfpath = $pl->_getRealMDFname();
if (PEAR::isError($plfpath)) {
return $plfpath;
}
$trtype = 'playlist';
}
$trec = $this->_uploadGeneralFileToHub($plfpath, $trtype,
array_merge(array('gunid'=>$plid,'fname'=>$fname,), $pars));
if (PEAR::isError($trec)) {
return $trec;
}
break;
default:
return PEAR::raiseError("Transport::upload2Hub: ftype not supported ($ftype)");
} }
$this->startCronJobProcess($trec->trtok); $this->startCronJobProcess($trec->trtok);
$this->trLog("upload2Hub end: ".strftime("%H:%M:%S"));
return $trec->trtok; return $trec->trtok;
} }
@ -412,22 +415,9 @@ class Transport
*/ */
function downloadFromHub($uid, $gunid, $withContent=TRUE, $pars=array()) function downloadFromHub($uid, $gunid, $withContent=TRUE, $pars=array())
{ {
# $this->trLog(var_export($gunid, TRUE));
$trtype = ($withContent ? 'playlistPkg' : 'unknown' ); $trtype = ($withContent ? 'playlistPkg' : 'unknown' );
$trec = TransportRecord::create($this, $trtype, 'down', $trec = TransportRecord::create($this, $trtype, 'down',
array_merge(array('gunid'=>$gunid, 'uid'=>$uid), $pars) array_merge(array('gunid'=>$gunid, 'uid'=>$uid), $pars));
/* merged !???
array(
'trtok' => '123456789abcdef2',
),
array(
'trtok' => '123456789abcdef3',
),
array(
'trtok' => '123456789abcdef4',
),
*/
);
if (PEAR::isError($trec)) { if (PEAR::isError($trec)) {
return $trec; return $trec;
} }
@ -464,7 +454,6 @@ class Transport
return $r; return $r;
} }
$this->logoutFromArchive($r); $this->logoutFromArchive($r);
// ----------
$criteria['resultMode'] = $resultMode; $criteria['resultMode'] = $resultMode;
$localfile = tempnam($this->transDir, 'searchjob_'); $localfile = tempnam($this->transDir, 'searchjob_');
@chmod($localfile, 0660); @chmod($localfile, 0660);
@ -494,7 +483,6 @@ class Transport
if (PEAR::isError($trec)) { if (PEAR::isError($trec)) {
return $trec; return $trec;
} }
//echo"<pre>";print_r($trec);echo "</pre>";
$row = $trec->row; $row = $trec->row;
switch ($st = $trec->getState()) { switch ($st = $trec->getState()) {
case "failed": case "failed":