CC-2282 Import script does not restore storage from backup if database is intact
not considering a duplicate to exist just because there's a row in the database, checking if its file exists on the system as well.
This commit is contained in:
parent
05e02f6081
commit
71ac8d4b1b
2 changed files with 52 additions and 8 deletions
|
@ -734,7 +734,14 @@ class StoredFile {
|
|||
$storedFile->mtime = $row['mtime'];
|
||||
$storedFile->md5 = $row['md5'];
|
||||
$storedFile->filepath = $row['filepath'];
|
||||
$storedFile->exists = TRUE;
|
||||
|
||||
if(file_exists($row['filepath'])) {
|
||||
$storedFile->exists = true;
|
||||
}
|
||||
else {
|
||||
$storedFile->exists = false;
|
||||
}
|
||||
|
||||
$storedFile->setFormat($row['ftype']);
|
||||
return $storedFile;
|
||||
}
|
||||
|
@ -867,7 +874,7 @@ class StoredFile {
|
|||
* local path
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
public function replaceFile($p_localFilePath)
|
||||
public function replaceFile($p_localFilePath, $p_copyMedia=TRUE)
|
||||
{
|
||||
// Dont do anything if the source and destination files are
|
||||
// the same.
|
||||
|
@ -881,7 +888,7 @@ class StoredFile {
|
|||
return $r;
|
||||
}
|
||||
}
|
||||
return $this->addFile($p_localFilePath);
|
||||
return $this->addFile($p_localFilePath, $p_copyMedia);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1783,8 +1790,17 @@ class StoredFile {
|
|||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
|
||||
}
|
||||
else {
|
||||
$duplicateName = $duplicate->getMetadataValue(UI_MDATA_KEY_TITLE);
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}');
|
||||
if(file_exists($duplicate->getRealFilePath())) {
|
||||
$duplicateName = $duplicate->getMetadataValue(UI_MDATA_KEY_TITLE);
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}');
|
||||
}
|
||||
else{
|
||||
$res = $duplicate->replaceFile($audio_file);
|
||||
if (PEAR::isError($res)) {
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
|
||||
}
|
||||
return $duplicate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue