#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']);
|
||||
|
||||
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)) {
|
||||
import_err($r, "Error in bsPutFile()");
|
||||
echo var_export($mdata)."\n";
|
||||
|
|
|
@ -80,11 +80,13 @@ class BasicStor {
|
|||
* Internal file type
|
||||
* @param string $mdataLoc
|
||||
* 'file'|'string'
|
||||
* @param boolean $copyMedia
|
||||
* copy the media file if true, make symlink if false
|
||||
* @return int
|
||||
* @exception PEAR_Error
|
||||
*/
|
||||
public function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
|
||||
$gunid=NULL, $ftype='unknown', $mdataLoc='file')
|
||||
$gunid=NULL, $ftype='unknown', $mdataLoc='file', $copyMedia=TRUE)
|
||||
{
|
||||
$ftype = strtolower($ftype);
|
||||
$id = BasicStor::AddObj($fileName, $ftype, $parid);
|
||||
|
@ -92,7 +94,7 @@ class BasicStor {
|
|||
return $id;
|
||||
}
|
||||
$ac = StoredFile::insert($id, $fileName,
|
||||
$mediaFileLP, $mdataFileLP, $mdataLoc, $gunid, $ftype);
|
||||
$mediaFileLP, $mdataFileLP, $mdataLoc, $gunid, $ftype, 'StoredFile', $copyMedia);
|
||||
if (PEAR::isError($ac)) {
|
||||
$res = BasicStor::RemoveObj($id);
|
||||
// catch constraint violations
|
||||
|
|
|
@ -254,10 +254,12 @@ class RawMediaData {
|
|||
*
|
||||
* @param string $mediaFileLP
|
||||
* local path
|
||||
* @param boolean $copyMedia
|
||||
* copy the media file if true, make symlink if false
|
||||
* @return mixed
|
||||
* true or PEAR::error
|
||||
*/
|
||||
function insert($mediaFileLP)
|
||||
function insert($mediaFileLP, $copyMedia=TRUE)
|
||||
{
|
||||
if ($this->exists) {
|
||||
return FALSE;
|
||||
|
@ -268,7 +270,12 @@ class RawMediaData {
|
|||
return TRUE;
|
||||
}
|
||||
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;
|
||||
return TRUE;
|
||||
} else {
|
||||
|
|
|
@ -96,11 +96,13 @@ class StoredFile {
|
|||
* internal file type
|
||||
* @param string $className
|
||||
* class to be constructed
|
||||
* @param boolean $copyMedia
|
||||
* copy the media file if true, make symlink if false
|
||||
* @return StoredFile
|
||||
*/
|
||||
public static function &insert($oid, $name,
|
||||
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
||||
$gunid=NULL, $ftype=NULL, $className='StoredFile')
|
||||
$gunid=NULL, $ftype=NULL, $className='StoredFile', $copyMedia=TRUE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$ac = new $className(($gunid ? $gunid : NULL));
|
||||
|
@ -150,7 +152,7 @@ class StoredFile {
|
|||
return PEAR::raiseError("StoredFile::insert: ".
|
||||
"media file not found ($mediaFileLP)");
|
||||
}
|
||||
$res = $ac->rmd->insert($mediaFileLP);
|
||||
$res = $ac->rmd->insert($mediaFileLP, $copyMedia);
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
|
|
Loading…
Reference in New Issue