summaryrefslogtreecommitdiffstats
path: root/lib/private/preferences.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-12-03 21:31:29 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-08 22:33:36 +0100
commitaf91ee97c981d32bcd531e71d31e16f1232c44ce (patch)
treea38253e8311aa0056f90af6adc89d9b791d1dc00 /lib/private/preferences.php
parentf0b10324caf1637d8ad5a9ed94dfed084f65407d (diff)
downloadnextcloud-server-af91ee97c981d32bcd531e71d31e16f1232c44ce.tar.gz
nextcloud-server-af91ee97c981d32bcd531e71d31e16f1232c44ce.zip
introduce preCondition for setUserValue to provide atomic check-and-update
Diffstat (limited to 'lib/private/preferences.php')
-rw-r--r--lib/private/preferences.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/preferences.php b/lib/private/preferences.php
index 9f33136aeb2..cd4a9fd1c19 100644
--- a/lib/private/preferences.php
+++ b/lib/private/preferences.php
@@ -37,6 +37,7 @@
namespace OC;
use OCP\IDBConnection;
+use OCP\PreConditionNotMetException;
/**
@@ -111,10 +112,12 @@ class Preferences {
* will be added automagically.
*/
public function setValue($user, $app, $key, $value, $preCondition = null) {
- return $this->config->setUserValue($user, $app, $key, $value);
-
- // TODO maybe catch exceptions and then return false
- return true;
+ try {
+ $this->config->setUserValue($user, $app, $key, $value, $preCondition);
+ return true;
+ } catch(PreConditionNotMetException $e) {
+ return false;
+ }
}
/**