MINOR Checking for success of file upload before trying to add metadata in AssetAdmin->doUpload() (AIR-37)

This commit is contained in:
Ingo Schommer 2011-09-01 14:49:23 +02:00
parent 089973803b
commit 093eb6cd53

View File

@ -225,17 +225,17 @@ JS
// move file to given folder
if($valid) {
$newFile = $folder->addUploadToFolder($tmpFile);
if($newFile = $folder->addUploadToFolder($tmpFile)) {
if(self::$metadata_upload_enabled && isset($processedData[$filePostId])) {
$fileObject = DataObject::get_by_id('File', $newFile);
$metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldSet());
$metadataForm->loadDataFrom($processedData[$filePostId]);
$metadataForm->saveInto($fileObject);
$fileObject->write();
}
if(self::$metadata_upload_enabled && isset($processedData[$filePostId])) {
$fileObject = DataObject::get_by_id('File', $newFile);
$metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldSet());
$metadataForm->loadDataFrom($processedData[$filePostId]);
$metadataForm->saveInto($fileObject);
$fileObject->write();
$newFiles[] = $newFile;
}
$newFiles[] = $newFile;
}
}
}