Browse Source

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

comfortablynumb 13 years ago
parent
commit
573e61754c
1 changed files with 3 additions and 1 deletions
  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 ($config = $this->getConfiguration($om, $meta->name)) {
                 if (isset($config['uploadable']) && $config['uploadable']) {
                 if (isset($config['uploadable']) && $config['uploadable']) {
-                    $this->removeFile($meta, $config, $object);
                     $this->processFile($uow, $ea, $meta, $config, $object, self::ACTION_UPDATE);
                     $this->processFile($uow, $ea, $meta, $config, $object, self::ACTION_UPDATE);
                 }
                 }
             }
             }
@@ -139,6 +138,9 @@ class UploadableListener extends MappedEventSubscriber
 
 
             foreach ($file as $id => $f) {
             foreach ($file as $id => $f) {
                 if ($action === self::ACTION_INSERT || $id === $identifier) {
                 if ($action === self::ACTION_INSERT || $id === $identifier) {
+                    // First we remove the original file
+                    $this->removefile($meta, $config, $object);
+
                     $info = $this->moveFile($f, $path);
                     $info = $this->moveFile($f, $path);
                     $filePathField->setValue($object, $info['filePath']);
                     $filePathField->setValue($object, $info['filePath']);
                     $changes = array(
                     $changes = array(