diff options
author | Björn Schießle <schiessle@owncloud.com> | 2016-04-21 14:26:41 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2016-04-21 14:26:41 +0200 |
commit | 80959ad95ac75783babf2a224a7af044a858fa08 (patch) | |
tree | d1a68e1eb152a3d02082534b28487546cae8ba55 /apps/files_versions | |
parent | e673ff0f330425ac37697e2ce2f262888289b406 (diff) | |
parent | 9ebae0bdeb2882dbe356f7bd691492ac0c55c1fa (diff) | |
download | nextcloud-server-80959ad95ac75783babf2a224a7af044a858fa08.tar.gz nextcloud-server-80959ad95ac75783babf2a224a7af044a858fa08.zip |
Merge pull request #24111 from owncloud/chunk-users-in-background-jobs
Chunk the users correctly in the trashbin and versions background job
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/lib/backgroundjob/expireversions.php | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/apps/files_versions/lib/backgroundjob/expireversions.php b/apps/files_versions/lib/backgroundjob/expireversions.php index 5d8eef4e351..8e14e65b9a7 100644 --- a/apps/files_versions/lib/backgroundjob/expireversions.php +++ b/apps/files_versions/lib/backgroundjob/expireversions.php @@ -21,6 +21,7 @@ namespace OCA\Files_Versions\BackgroundJob; +use OCP\IUser; use OCP\IUserManager; use OCA\Files_Versions\AppInfo\Application; use OCA\Files_Versions\Storage; @@ -64,20 +65,13 @@ class ExpireVersions extends \OC\BackgroundJob\TimedJob { return; } - $users = $this->userManager->search(''); - $isFSready = false; - foreach ($users as $user) { + $this->userManager->callForAllUsers(function(IUser $user) { $uid = $user->getUID(); - if (!$isFSready) { - if (!$this->setupFS($uid)) { - continue; - } - $isFSready = true; + if (!$this->setupFS($uid)) { + return; } Storage::expireOlderThanMaxForUser($uid); - } - - \OC_Util::tearDownFS(); + }); } /** @@ -85,14 +79,16 @@ class ExpireVersions extends \OC\BackgroundJob\TimedJob { * @param string $user * @return boolean */ - private function setupFS($user){ - if (!$this->userManager->userExists($user)) { - return false; - } - + protected function setupFS($user) { \OC_Util::tearDownFS(); \OC_Util::setupFS($user); + // Check if this user has a versions directory + $view = new \OC\Files\View('/' . $user); + if (!$view->is_dir('/files_versions')) { + return false; + } + return true; } } |