]> source.dussan.org Git - nextcloud-server.git/commitdiff
use insertIfNotExist() in cache put
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 6 Mar 2015 14:32:58 +0000 (15:32 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 6 Mar 2015 14:32:58 +0000 (15:32 +0100)
lib/private/files/cache/cache.php

index 1f30382e10171644040cd3fb2528c304114d39e7..62c32ce65932f9117bdae8d6f485c18c616cb9d2 100644 (file)
@@ -243,13 +243,19 @@ class Cache {
                        list($queryParts, $params) = $this->buildParts($data);
                        $queryParts[] = '`storage`';
                        $params[] = $this->getNumericStorageId();
-                       $valuesPlaceholder = array_fill(0, count($queryParts), '?');
 
-                       $sql = 'INSERT INTO `*PREFIX*filecache` (' . implode(', ', $queryParts) . ')'
-                               . ' VALUES (' . implode(', ', $valuesPlaceholder) . ')';
-                       \OC_DB::executeAudited($sql, $params);
+                       $params = array_map(function($item) {
+                               return trim($item, "`");
+                       }, $params);
+                       $queryParts = array_map(function($item) {
+                               return trim($item, "`");
+                       }, $queryParts);
+                       $values = array_combine($queryParts, $params);
+                       if (\OC::$server->getDatabaseConnection()->insertIfNotExist('*PREFIX*filecache', $values)) {
+                               return (int)\OC_DB::insertid('*PREFIX*filecache');
+                       }
 
-                       return (int)\OC_DB::insertid('*PREFIX*filecache');
+                       return $this->getId($file);
                }
        }