Extra parameters added to resetStorage method

- flag for sampleData inserting and deleting only files in storage.
Default values have been chosen to preserve previous calls.
This commit is contained in:
tomash 2005-09-29 00:24:32 +00:00
parent 411e87590a
commit f4929ce3db
4 changed files with 47 additions and 15 deletions

View file

@ -39,7 +39,7 @@ echo "# storageServer root URL: $WWW_ROOT"
cd $reldir/var/xmlrpc
php -q xr_cli_test.php -s $WWW_ROOT/xmlrpc/xrLocStor.php \
resetStorage || exit $?
resetStorage 1 0 || exit $?
echo "# resetStorage: OK"
exit 0

View file

@ -1278,23 +1278,26 @@ class BasicStor extends Alib{
/**
* Reset storageServer for debugging.
*
* @param loadSampleData boolean - allows deny sample data loading
* @param loadSampleData boolean - flag for allow sample data loading
* @param filesOnly boolean - flag for operate only on files in storage
*/
function resetStorage($loadSampleData=TRUE)
function resetStorage($loadSampleData=TRUE, $filesOnly=FALSE)
{
$this->deleteData();
if($filesOnly) $this->deleteFiles();
else $this->deleteData();
if(!$this->config['isArchive']){
$tr =& new Transport($this->dbc, $this, $this->config);
$tr->resetData();
}
$res = array(
'audioclips'=>array(), 'playlists'=>array(), 'webstreams'=>array()
);
if(!$loadSampleData) return $res;
$rootHD = $this->getObjId('root', $this->storId);
$samples = dirname(__FILE__)."/tests/sampleData.php";
if(file_exists($samples)){
include $samples;
}else $sampleData = array();
$res = array(
'audioclips'=>array(), 'playlists'=>array(), 'webstreams'=>array()
);
foreach($sampleData as $k=>$it){
$type = $it['type'];
$xml = $it['xml'];
@ -1353,6 +1356,18 @@ class BasicStor extends Alib{
echo"<pre>\n"; print_r($va); #exit;
}
/**
* deleteFiles
*
* @return void
*/
function deleteFiles()
{
$ids = $this->dbc->getAll("SELECT id FROM {$this->filesTable}");
if(is_array($ids)) foreach($ids as $i=>$item){
$this->bsDeleteFile($item['id'], TRUE);
}
}
/**
* deleteData
*
@ -1360,11 +1375,7 @@ class BasicStor extends Alib{
*/
function deleteData()
{
// $this->dbc->query("DELETE FROM {$this->filesTable}");
$ids = $this->dbc->getAll("SELECT id FROM {$this->filesTable}");
if(is_array($ids)) foreach($ids as $i=>$item){
$this->bsDeleteFile($item['id'], TRUE);
}
$this->deleteFiles();
parent::deleteData();
$this->initData();
}

View file

@ -1870,7 +1870,15 @@ class XR_LocStor extends LocStor{
*
* The XML-RPC name of this method is "locstor.resetStorage".
*
* The input parameters are an empty XML-RPC struct.
* The input parameters are an empty XML-RPC struct,
* or struct with the following <b>optional</b> fields:
* <ul>
* <li> loadSampleData : boolean - flag for allow sample data loading
* </li>
* <li> filesOnly : boolean - flag for files cleanup only,
* no sampleData insert
* </li>
* </ul>
*
* On success, returns a XML-RPC struct with following
* fields:
@ -1899,7 +1907,10 @@ class XR_LocStor extends LocStor{
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
$res = $this->resetStorage();
$res = $this->resetStorage(
isset($r['loadSampleData']) ? $r['loadSampleData'] : TRUE,
isset($r['filesOnly']) ? $r['filesOnly'] : FALSE
);
if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()

View file

@ -51,6 +51,7 @@ $client = new XML_RPC_Client($url['path'], $url['host']);
$method = array_shift($pars);
if($verbose){
$client->debug = 1;
echo "serverPath: $serverPath\n";
echo "host: {$url['host']}, path: {$url['path']}\n";
echo "method: $method\n";
@ -105,7 +106,9 @@ $infos = array(
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
"browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL),
"resetStorage" => array('m'=>"locstor.resetStorage", 'p'=>array()),
"resetStorage" => array('m'=>"locstor.resetStorage",
'p'=>array()),
# 'p'=>array('loadSampleData', 'filesOnly')),
"storeWebstream" => array('m'=>"locstor.storeWebstream",
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'),
'r'=>array('gunid')
@ -184,6 +187,12 @@ case"browseCategory":
),
);
break;
case"resetStorage":
$parr = array(
'loadSampleData'=>(boolean)$pars[0],
'filesOnly'=>(boolean)$pars[1],
);
break;
default:
$pinfo = $infos[$method]['p'];
if(is_null($pinfo)){
@ -215,6 +224,7 @@ if($verbose){
$res = $client->send($msg);
if($res->faultCode() > 0) {
echo "xr_cli_test.php: ".$res->faultString()." ".$res->faultCode()."\n";
# echo var_export($res);
exit(1);
}