Skip to content

Commit b9d69c9

Browse files
juliusknorrbackportbot[bot]
authored andcommitted
fix: Allow to write default values so we know if the folder has been set manually
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 726a8dc commit b9d69c9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/Service/NoteUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function getOrCreateNotesFolder(string $userId, bool $create = true) : Fo
204204
if ($updateNotesPath) {
205205
$this->settingsService->set($userId, [
206206
'notesPath' => $notesPath,
207-
]);
207+
], true);
208208
}
209209

210210
return $folder;

lib/Service/SettingsService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function getDefaultNotesPath(string $uid) : string {
9494
/**
9595
* @throws \OCP\PreConditionNotMetException
9696
*/
97-
public function set(string $uid, array $settings) : void {
97+
public function set(string $uid, array $settings, bool $writeDefaults = false) : void {
9898
// load existing values for missing attributes
9999
$oldSettings = $this->getSettingsFromDB($uid);
100100
foreach ($oldSettings as $name => $value) {
@@ -108,10 +108,10 @@ public function set(string $uid, array $settings) : void {
108108
$settings[$name] = $value = $this->attrs[$name]['validate']($value);
109109
}
110110
$default = is_callable($this->attrs[$name]['default']) ? $this->attrs[$name]['default']($uid) : $this->attrs[$name]['default'];
111-
if (!array_key_exists($name, $this->attrs)
111+
if (!$writeDefaults && (!array_key_exists($name, $this->attrs)
112112
|| $value === null
113113
|| $value === $default
114-
) {
114+
)) {
115115
unset($settings[$name]);
116116
}
117117
}

0 commit comments

Comments
 (0)