use insertIfNotExist() in cache put
This commit is contained in:
parent
4e37831d85
commit
1b08b7c726
1 changed files with 11 additions and 5 deletions
16
lib/private/files/cache/cache.php
vendored
16
lib/private/files/cache/cache.php
vendored
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue