소스 검색

[Uploadable] Only remove original file if there's an update going on

comfortablynumb 13 년 전
부모
커밋
573e61754c
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      lib/Gedmo/Uploadable/UploadableListener.php

+ 3 - 1
lib/Gedmo/Uploadable/UploadableListener.php

@@ -72,7 +72,6 @@ class UploadableListener extends MappedEventSubscriber
 
             if ($config = $this->getConfiguration($om, $meta->name)) {
                 if (isset($config['uploadable']) && $config['uploadable']) {
-                    $this->removeFile($meta, $config, $object);
                     $this->processFile($uow, $ea, $meta, $config, $object, self::ACTION_UPDATE);
                 }
             }
@@ -139,6 +138,9 @@ class UploadableListener extends MappedEventSubscriber
 
             foreach ($file as $id => $f) {
                 if ($action === self::ACTION_INSERT || $id === $identifier) {
+                    // First we remove the original file
+                    $this->removefile($meta, $config, $object);
+
                     $info = $this->moveFile($f, $path);
                     $filePathField->setValue($object, $info['filePath']);
                     $changes = array(