summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2015-01-29 15:24:53 +0100
committerJoas Schilling <nickvergessen@gmx.de>2015-02-23 10:44:30 +0100
commitee83fa673e6b8467fe22d1ec9a0eba6aa792e651 (patch)
treeb2be87ae5925d3be2f51563f2029ddbf548f3062 /lib/private
parent033635c9fb68d1051e25eaec40bbf583f1491581 (diff)
downloadnextcloud-server-ee83fa673e6b8467fe22d1ec9a0eba6aa792e651.tar.gz
nextcloud-server-ee83fa673e6b8467fe22d1ec9a0eba6aa792e651.zip
Use insertIfNotExists() and reload mimetypes after inserting one
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/files/cache/cache.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 5438bdad5cb..3c097a34962 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -74,9 +74,11 @@ class Cache {
if (!isset(self::$mimetypeIds[$mime])) {
try {
- $result = \OC_DB::executeAudited('INSERT INTO `*PREFIX*mimetypes`(`mimetype`) VALUES(?)', array($mime));
- self::$mimetypeIds[$mime] = \OC_DB::insertid('*PREFIX*mimetypes');
- self::$mimetypes[self::$mimetypeIds[$mime]] = $mime;
+ $connection = \OC_DB::getConnection();
+ $connection->insertIfNotExist('*PREFIX*mimetypes', [
+ 'mimetype' => $mime,
+ ]);
+ $this->loadMimetypes();
} catch (\Doctrine\DBAL\DBALException $e) {
\OC_Log::write('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OC_Log::DEBUG);
return -1;
@@ -95,6 +97,8 @@ class Cache {
}
public function loadMimetypes() {
+ self::$mimetypeIds = self::$mimetypes = array();
+
$result = \OC_DB::executeAudited('SELECT `id`, `mimetype` FROM `*PREFIX*mimetypes`', array());
if ($result) {
while ($row = $result->fetchRow()) {