]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Delete successfully generated thumbnail (temporary sources) too.
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 15 Jul 2016 10:52:01 +0000 (12:52 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 15 Jul 2016 10:52:20 +0000 (12:52 +0200)
lib/imagefile.php

index b0cd13089f64e1579d456473b6601a09801f31cb..626221d9a84549b36971c5f4c7a861a8b4d44f0a 100644 (file)
@@ -151,10 +151,14 @@ class ImageFile
 
         try {
             $image = new ImageFile($file->getID(), $imgPath);
-        } catch (UnsupportedMediaException $e) {
+        } catch (Exception $e) {
+            common_debug(sprintf('Exception caught when creating ImageFile for File id==%s and imgPath==', _ve($file->id), _ve($imgPath)));
+            throw $e;
+        } finally {
             // Avoid deleting the original
             try {
-                if ($imgPath !== $file->getPath()) {
+                if (strlen($imgPath) > 0 && $imgPath !== $file->getPath()) {
+                    common_debug(__METHOD__.': Deleting temporary file that was created as image file thumbnail source: '._ve($imgPath));
                     @unlink($imgPath);
                 }
             } catch (FileNotFoundException $e) {
@@ -162,7 +166,6 @@ class ImageFile
                 // doesn't exist anyway, so it's safe to delete $imgPath
                 @unlink($imgPath);
             }
-            throw $e;
         }
         return $image;
     }