diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index b7f625bc35d60..7b42cc2aa5704 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -3,7 +3,6 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Andreas Fischer - * @author Ari Selseng * @author Artem Kochnev * @author Björn Schießle * @author Florin Peter @@ -846,14 +845,15 @@ public function getAll() { /** * find a folder in the cache which has not been fully scanned * - * If multiple incomplete folders are in the cache, the top-most folder will be returned - * This avoids a weird edge case when multiple incomplete folders do not get scanned properly + * If multiple incomplete folders are in the cache, the one with the highest id will be returned, + * use the one with the highest id gives the best result with the background scanner, since that is most + * likely the folder where we stopped scanning previously * * @return string|bool the path of the folder or false when no folder matched */ public function getIncomplete() { $query = $this->connection->prepare('SELECT `path` FROM `*PREFIX*filecache`' - . ' WHERE `storage` = ? AND `size` = -1 ORDER BY `path` ASC', 1); + . ' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC', 1); $query->execute([$this->getNumericStorageId()]); if ($row = $query->fetch()) { return $row['path'];