]> source.dussan.org Git - nextcloud-server.git/commitdiff
restart transaction when cache insert fails due to duplicate 19486/head
authorRobin Appelman <robin@icewind.nl>
Fri, 28 Feb 2020 16:36:38 +0000 (17:36 +0100)
committerRobin Appelman <robin@icewind.nl>
Wed, 1 Apr 2020 12:17:34 +0000 (14:17 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Cache/Cache.php

index e57124d6cbdfa0d65a7df8c8e74d4abc36c00010..11f7eedea26a3e4e4c6f5911b5cf160b3b6414e6 100644 (file)
@@ -309,6 +309,10 @@ class Cache implements ICache {
                        }
                } catch (UniqueConstraintViolationException $e) {
                        // entry exists already
+                       if ($this->connection->inTransaction()) {
+                               $this->connection->commit();
+                               $this->connection->beginTransaction();
+                       }
                }
 
                // The file was created in the mean time
@@ -611,8 +615,8 @@ class Cache implements ICache {
                        $sourceId = $sourceData['fileid'];
                        $newParentId = $this->getParentId($targetPath);
 
-                       list($sourceStorageId, $sourcePath) = $sourceCache->getMoveInfo($sourcePath);
-                       list($targetStorageId, $targetPath) = $this->getMoveInfo($targetPath);
+                       [$sourceStorageId, $sourcePath] = $sourceCache->getMoveInfo($sourcePath);
+                       [$targetStorageId, $targetPath] = $this->getMoveInfo($targetPath);
 
                        if (is_null($sourceStorageId) || $sourceStorageId === false) {
                                throw new \Exception('Invalid source storage id: ' . $sourceStorageId);
@@ -882,7 +886,7 @@ class Cache implements ICache {
                                ->whereParent($id);
 
                        if ($row = $query->execute()->fetch()) {
-                               list($sum, $min) = array_values($row);
+                               [$sum, $min] = array_values($row);
                                $sum = 0 + $sum;
                                $min = 0 + $min;
                                if ($min === -1) {