From 093eb6cd532d917257c8f9c73610d5d0f02936ce Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 1 Sep 2011 14:49:23 +0200 Subject: [PATCH] MINOR Checking for success of file upload before trying to add metadata in AssetAdmin->doUpload() (AIR-37) --- code/controllers/AssetAdmin.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/code/controllers/AssetAdmin.php b/code/controllers/AssetAdmin.php index 490f5c7d..7c792873 100644 --- a/code/controllers/AssetAdmin.php +++ b/code/controllers/AssetAdmin.php @@ -225,17 +225,17 @@ JS // move file to given folder if($valid) { - $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($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(); + } + + $newFiles[] = $newFile; } - - $newFiles[] = $newFile; } } }