Check if the user exists before trying to set the quota

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Juan Pablo Villafáñez 2017-03-14 17:08:05 +01:00 committed by Arthur Schiwon
parent 3345a72e7e
commit f9832ff347
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 9 additions and 4 deletions

View File

@ -498,11 +498,16 @@ class User {
}
}
if($quota !== false) {
$this->userManager->get($this->uid)->setQuota($quota);
$targetUser = $this->userManager->get($this->uid);
if ($targetUser) {
if($quota !== false) {
$targetUser->setQuota($quota);
} else {
$this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN);
$targetUser->setQuota('default');
}
} else {
$this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN);
$this->userManager->get($this->uid)->setQuota('default');
$this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::ERROR);
}
}