#1855 copying of media files replaces by making symlink in import script
This commit is contained in:
parent
558d968e5f
commit
1cbc14025c
|
@ -96,7 +96,7 @@ while ($filename = fgets($stdin, 2048)) {
|
||||||
unset($mdata['playtime_seconds']);
|
unset($mdata['playtime_seconds']);
|
||||||
|
|
||||||
if (!$testonly) {
|
if (!$testonly) {
|
||||||
$r = $gb->bsPutFile($parid, $mdata['ls:filename'], "$filename", "$storageServerPath/var/emptyMdata.xml", NULL, 'audioclip');
|
$r = $gb->bsPutFile($parid, $mdata['ls:filename'], "$filename", "$storageServerPath/var/emptyMdata.xml", NULL, 'audioclip', 'file', FALSE);
|
||||||
if (PEAR::isError($r)) {
|
if (PEAR::isError($r)) {
|
||||||
import_err($r, "Error in bsPutFile()");
|
import_err($r, "Error in bsPutFile()");
|
||||||
echo var_export($mdata)."\n";
|
echo var_export($mdata)."\n";
|
||||||
|
|
|
@ -80,11 +80,13 @@ class BasicStor {
|
||||||
* Internal file type
|
* Internal file type
|
||||||
* @param string $mdataLoc
|
* @param string $mdataLoc
|
||||||
* 'file'|'string'
|
* 'file'|'string'
|
||||||
|
* @param boolean $copyMedia
|
||||||
|
* copy the media file if true, make symlink if false
|
||||||
* @return int
|
* @return int
|
||||||
* @exception PEAR_Error
|
* @exception PEAR_Error
|
||||||
*/
|
*/
|
||||||
public function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
|
public function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
|
||||||
$gunid=NULL, $ftype='unknown', $mdataLoc='file')
|
$gunid=NULL, $ftype='unknown', $mdataLoc='file', $copyMedia=TRUE)
|
||||||
{
|
{
|
||||||
$ftype = strtolower($ftype);
|
$ftype = strtolower($ftype);
|
||||||
$id = BasicStor::AddObj($fileName, $ftype, $parid);
|
$id = BasicStor::AddObj($fileName, $ftype, $parid);
|
||||||
|
@ -92,7 +94,7 @@ class BasicStor {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
$ac = StoredFile::insert($id, $fileName,
|
$ac = StoredFile::insert($id, $fileName,
|
||||||
$mediaFileLP, $mdataFileLP, $mdataLoc, $gunid, $ftype);
|
$mediaFileLP, $mdataFileLP, $mdataLoc, $gunid, $ftype, 'StoredFile', $copyMedia);
|
||||||
if (PEAR::isError($ac)) {
|
if (PEAR::isError($ac)) {
|
||||||
$res = BasicStor::RemoveObj($id);
|
$res = BasicStor::RemoveObj($id);
|
||||||
// catch constraint violations
|
// catch constraint violations
|
||||||
|
|
|
@ -254,10 +254,12 @@ class RawMediaData {
|
||||||
*
|
*
|
||||||
* @param string $mediaFileLP
|
* @param string $mediaFileLP
|
||||||
* local path
|
* local path
|
||||||
|
* @param boolean $copyMedia
|
||||||
|
* copy the media file if true, make symlink if false
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* true or PEAR::error
|
* true or PEAR::error
|
||||||
*/
|
*/
|
||||||
function insert($mediaFileLP)
|
function insert($mediaFileLP, $copyMedia=TRUE)
|
||||||
{
|
{
|
||||||
if ($this->exists) {
|
if ($this->exists) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -268,7 +270,12 @@ class RawMediaData {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
umask(0002);
|
umask(0002);
|
||||||
if (@copy($mediaFileLP, $this->fname)) {
|
if ($copyMedia) {
|
||||||
|
$r = @copy($mediaFileLP, $this->fname);
|
||||||
|
} else {
|
||||||
|
$r = @symlink($mediaFileLP, $this->fname);
|
||||||
|
}
|
||||||
|
if ( $r ) {
|
||||||
$this->exists = TRUE;
|
$this->exists = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -96,11 +96,13 @@ class StoredFile {
|
||||||
* internal file type
|
* internal file type
|
||||||
* @param string $className
|
* @param string $className
|
||||||
* class to be constructed
|
* class to be constructed
|
||||||
|
* @param boolean $copyMedia
|
||||||
|
* copy the media file if true, make symlink if false
|
||||||
* @return StoredFile
|
* @return StoredFile
|
||||||
*/
|
*/
|
||||||
public static function &insert($oid, $name,
|
public static function &insert($oid, $name,
|
||||||
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
||||||
$gunid=NULL, $ftype=NULL, $className='StoredFile')
|
$gunid=NULL, $ftype=NULL, $className='StoredFile', $copyMedia=TRUE)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$ac = new $className(($gunid ? $gunid : NULL));
|
$ac = new $className(($gunid ? $gunid : NULL));
|
||||||
|
@ -150,7 +152,7 @@ class StoredFile {
|
||||||
return PEAR::raiseError("StoredFile::insert: ".
|
return PEAR::raiseError("StoredFile::insert: ".
|
||||||
"media file not found ($mediaFileLP)");
|
"media file not found ($mediaFileLP)");
|
||||||
}
|
}
|
||||||
$res = $ac->rmd->insert($mediaFileLP);
|
$res = $ac->rmd->insert($mediaFileLP, $copyMedia);
|
||||||
if (PEAR::isError($res)) {
|
if (PEAR::isError($res)) {
|
||||||
$CC_DBC->query("ROLLBACK");
|
$CC_DBC->query("ROLLBACK");
|
||||||
return $res;
|
return $res;
|
||||||
|
|
Loading…
Reference in New Issue