]> source.dussan.org Git - nextcloud-server.git/commitdiff
stop background scan early if a users still has unscanned files after background...
authorRobin Appelman <robin@icewind.nl>
Wed, 17 Nov 2021 14:04:51 +0000 (15:04 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 2 Dec 2021 17:47:05 +0000 (17:47 +0000)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files/lib/BackgroundJob/ScanFiles.php

index 37416aed521e9d70fce934d3388781bec174efa5..250338e12629bb41d0f0c2c6201f67fc589da9eb 100644 (file)
@@ -116,11 +116,17 @@ class ScanFiles extends \OC\BackgroundJob\TimedJob {
                }
 
                $usersScanned = 0;
+               $lastUser = '';
                $user = $this->getUserToScan();
-               while ($user && $usersScanned < self::USERS_PER_SESSION) {
+               while ($user && $usersScanned < self::USERS_PER_SESSION && $lastUser !== $user) {
                        $this->runScanner($user);
+                       $lastUser = $user;
                        $user = $this->getUserToScan();
                        $usersScanned += 1;
                }
+
+               if ($lastUser === $user) {
+                       $this->logger->warning("User $user still has unscanned files after running background scan, background scan might be stopped prematurely");
+               }
        }
 }