]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix first time image loading error
authorBartek Przybylski <bart.p.pl@gmail.com>
Sun, 10 Jun 2012 11:04:42 +0000 (13:04 +0200)
committerBartek Przybylski <bart.p.pl@gmail.com>
Sun, 10 Jun 2012 11:19:22 +0000 (13:19 +0200)
apps/gallery/lib/managers.php

index f9a67b8b117b5811d2c01f226ecdb362433c29b1..9a2dbd3bae2d8e6fd4b8d97c52fdc2b7abaf23a4 100644 (file)
@@ -26,10 +26,8 @@ class DatabaseManager {
                if (!$image->loadFromFile($path)) {
                        return false;
                }
-               \OCP\DB::beginTransaction();
                $stmt = \OCP\DB::prepare('INSERT INTO *PREFIX*pictures_images_cache (uid_owner, path, width, height) VALUES (?, ?, ?, ?)');
                $stmt->execute(array(\OCP\USER::getUser(), $path, $image->width(), $image->height()));
-               \OCP\DB::commit();
                $ret = array('path' => $path, 'width' => $image->width(), 'height' => $image->height());
                unset($image);
                return $ret;
@@ -78,9 +76,14 @@ class ThumbnailsManager {
        
        public function getThumbnailInfo($path) {
                $arr = DatabaseManager::getInstance()->getFileData($path);
+               if (!$arr) {
+                       $thubnail = $this->getThumbnail($path);
+                       unset($thubnail);
+                       $arr = DatabaseManager::getInstance()->getFileData($path);
+               }
                $ret = array('filepath' => $arr['path'],
-                                                                'width' => $arr['width'],
-                                                                'height' => $arr['height']);
+                                        'width' => $arr['width'],
+                                        'height' => $arr['height']);
                return $ret;
        }