diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-20 17:39:17 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-20 17:39:17 +0100 |
commit | 3a6b11d018e693b61cf201232bf5566f1a540b77 (patch) | |
tree | f64f75914a0495bb2489a67ce817465c0ccb4df6 /lib/private | |
parent | df2e712a8e84b3e12d5a54e3526ab996791e658e (diff) | |
parent | a575dcf78f0e69bc9fd43d32030f74b12b128af1 (diff) | |
download | nextcloud-server-3a6b11d018e693b61cf201232bf5566f1a540b77.tar.gz nextcloud-server-3a6b11d018e693b61cf201232bf5566f1a540b77.zip |
Merge pull request #13767 from owncloud/issue/13764-mimetype-racecondition
Use insertIfNotExists() and reload mimetypes after inserting one
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/cache/cache.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index 48b2b5c024b..1f30382e101 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()) { |