[BUGFIX] Use ResourceStorage::replaceFile for upload + replace 05/38505/2
authorFrans Saris <franssaris@gmail.com>
Tue, 7 Apr 2015 09:04:58 +0000 (11:04 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 25 Jun 2015 09:13:07 +0000 (11:13 +0200)
Resolves: #65089
Releases: master
Change-Id: Ic59e525c6e06c8b0ff71da8ff01f536f0a7059fa
Reviewed-on: http://review.typo3.org/38505
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Frederic Gaus <frederic.gaus@flagbit.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index 8e1aabd..f7c1012 100644 (file)
@@ -1770,9 +1770,14 @@ class ResourceStorage implements ResourceStorageInterface {
                if ($targetFileName === NULL) {
                        $targetFileName = $uploadedFileData['name'];
                }
-               // Handling $conflictMode is delegated to addFile()
+
                $this->assureFileUploadPermissions($localFilePath, $targetFolder, $targetFileName, $uploadedFileData['size']);
-               $resultObject = $this->addFile($localFilePath, $targetFolder, $targetFileName, $conflictMode);
+               if ($this->hasFileInFolder($targetFileName, $targetFolder) && $conflictMode === 'replace') {
+                       $file = $this->getFileInFolder($targetFileName, $targetFolder);
+                       $resultObject = $this->replaceFile($file, $localFilePath);
+               } else {
+                       $resultObject = $this->addFile($localFilePath, $targetFolder, $targetFileName, $conflictMode);
+               }
                return $resultObject;
        }