summaryrefslogtreecommitdiffstats
path: root/lib/private/files/cache
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-06 15:32:58 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-06 15:32:58 +0100
commit1b08b7c726e29ae9d7b9db2c8e2450fd751b9ab7 (patch)
treedd0726258ba99d91d720b3436c544622efdcfa26 /lib/private/files/cache
parent4e37831d85a1da443b73567c9c6d37c465dbda14 (diff)
downloadnextcloud-server-1b08b7c726e29ae9d7b9db2c8e2450fd751b9ab7.tar.gz
nextcloud-server-1b08b7c726e29ae9d7b9db2c8e2450fd751b9ab7.zip
use insertIfNotExist() in cache put
Diffstat (limited to 'lib/private/files/cache')
-rw-r--r--lib/private/files/cache/cache.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 1f30382e101..62c32ce6593 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -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);
}
}