Skip to content

Commit 05c493e

Browse files
committed
fix: saveInitial set to true in case of the capabilities
Signed-off-by: Enjeck C. <patrathewhiz@gmail.com>
1 parent 4095228 commit 05c493e

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

lib/AppInfo/Capabilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getCapabilities(): array {
2626
Application::APP_ID => [
2727
'api_version' => Application::$API_VERSIONS,
2828
'version' => $this->appManager->getAppVersion(Application::APP_ID),
29-
'notes_path' => $this->userId !== null && $this->userId !== ' ' ? $this->noteUtil->getNotesFolderUserPath($this->userId) : null,
29+
'notes_path' => $this->userId !== null && $this->userId !== ' ' ? $this->noteUtil->getNotesFolderUserPath($this->userId, true) : null,
3030
],
3131
];
3232
}

lib/Service/NoteUtil.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ public function getOrCreateFolder(string $path, bool $create = true) : Folder {
183183
return $folder;
184184
}
185185

186-
public function getNotesFolderUserPath(string $userId): ?string {
186+
public function getNotesFolderUserPath(string $userId, bool $saveInitial = false): ?string {
187187
try {
188-
$notesFolder = $this->settingsService->get($userId, 'notesPath');
188+
$notesFolder = $this->settingsService->get($userId, 'notesPath', $saveInitial);
189189
return $notesFolder;
190190
} catch (NotesFolderException $e) {
191191
$this->util->logger->debug("Failed to get notes folder for user $userId: " . $e->getMessage());

lib/Service/SettingsService.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,18 @@ public function getAll(string $uid, $saveInitial = false) : \stdClass {
152152
$settings = $this->getSettingsFromDB($uid);
153153
// use default for empty settings
154154
$toBeSaved = false;
155-
$toSaveNotesPath = false;
156155
foreach ($this->attrs as $name => $attr) {
157156
if (!property_exists($settings, $name)) {
158157
$defaultValue = $attr['default'];
159158
if (is_callable($defaultValue)) {
160159
$settings->{$name} = $defaultValue($uid);
161160
$toBeSaved = $saveInitial;
162-
if ($name === 'notesPath') {
163-
$toSaveNotesPath = true;
164-
}
165161
} else {
166162
$settings->{$name} = $defaultValue;
167163
}
168164
}
169165
}
170-
if ($toSaveNotesPath || $toBeSaved) {
166+
if ($toBeSaved) {
171167
$this->set($uid, (array)$settings);
172168
}
173169
return $settings;
@@ -176,8 +172,8 @@ public function getAll(string $uid, $saveInitial = false) : \stdClass {
176172
/**
177173
* @throws \OCP\PreConditionNotMetException
178174
*/
179-
public function get(string $uid, string $name) : string {
180-
$settings = $this->getAll($uid);
175+
public function get(string $uid, string $name, bool $saveInitial = false) : string {
176+
$settings = $this->getAll($uid, $saveInitial);
181177
if (property_exists($settings, $name)) {
182178
return $settings->{$name};
183179
} else {

0 commit comments

Comments
 (0)