11<?php
2+
23/**
34 * @copyright Copyright (c) 2016, ownCloud, Inc.
45 *
@@ -87,7 +88,7 @@ class Cache implements ICache {
8788 protected array $ partial = [];
8889 protected string $ storageId ;
8990 protected Storage $ storageCache ;
90- protected IMimeTypeLoader $ mimetypeLoader ;
91+ protected IMimeTypeLoader $ mimetypeLoader ;
9192 protected IDBConnection $ connection ;
9293 protected SystemConfig $ systemConfig ;
9394 protected LoggerInterface $ logger ;
@@ -876,7 +877,7 @@ public function search($pattern) {
876877 * search for files by mimetype
877878 *
878879 * @param string $mimetype either a full mimetype to search ('text/plain') or only the first part of a mimetype ('image')
879- * where it will search for all mimetypes in the group ('image/*')
880+ * where it will search for all mimetypes in the group ('image/*')
880881 * @return ICacheEntry[] an array of cache entries where the mimetype matches the search
881882 */
882883 public function searchByMime ($ mimetype ) {
@@ -1068,28 +1069,19 @@ public function getAll() {
10681069 * @return string|false the path of the folder or false when no folder matched
10691070 */
10701071 public function getIncomplete () {
1071- // we select the fileid here first instead of directly selecting the path since this helps mariadb/mysql
1072- // to use the correct index.
1073- // The overhead of this should be minimal since the cost of selecting the path by id should be much lower
1074- // than the cost of finding an item with size < 0
10751072 $ query = $ this ->getQueryBuilder ();
1076- $ query ->select ('fileid ' )
1073+ $ query ->select ('path ' )
10771074 ->from ('filecache ' )
10781075 ->whereStorageId ($ this ->getNumericStorageId ())
1079- ->andWhere ($ query ->expr ()->lt ('size ' , $ query ->createNamedParameter (0 , IQueryBuilder::PARAM_INT )))
1076+ ->andWhere ($ query ->expr ()->eq ('size ' , $ query ->createNamedParameter (- 1 , IQueryBuilder::PARAM_INT )))
10801077 ->orderBy ('fileid ' , 'DESC ' )
10811078 ->setMaxResults (1 );
10821079
10831080 $ result = $ query ->execute ();
1084- $ id = $ result ->fetchOne ();
1081+ $ path = $ result ->fetchOne ();
10851082 $ result ->closeCursor ();
10861083
1087- if ($ id === false ) {
1088- return false ;
1089- }
1090-
1091- $ path = $ this ->getPathById ($ id );
1092- return $ path ?? false ;
1084+ return $ path === false ? false : (string )$ path ;
10931085 }
10941086
10951087 /**
@@ -1169,7 +1161,7 @@ public function normalize($path) {
11691161 */
11701162 public function copyFromCache (ICache $ sourceCache , ICacheEntry $ sourceEntry , string $ targetPath ): int {
11711163 if ($ sourceEntry ->getId () < 0 ) {
1172- throw new \RuntimeException (" Invalid source cache entry on copyFromCache " );
1164+ throw new \RuntimeException (' Invalid source cache entry on copyFromCache ' );
11731165 }
11741166 $ data = $ this ->cacheEntryToArray ($ sourceEntry );
11751167
@@ -1180,7 +1172,7 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
11801172
11811173 $ fileId = $ this ->put ($ targetPath , $ data );
11821174 if ($ fileId <= 0 ) {
1183- throw new \RuntimeException (" Failed to copy to " . $ targetPath . " from cache with source data " . json_encode ($ data ) . " " );
1175+ throw new \RuntimeException (' Failed to copy to ' . $ targetPath . ' from cache with source data ' . json_encode ($ data ) . ' ' );
11841176 }
11851177 if ($ sourceEntry ->getMimeType () === ICacheEntry::DIRECTORY_MIMETYPE ) {
11861178 $ folderContent = $ sourceCache ->getFolderContentsById ($ sourceEntry ->getId ());
0 commit comments