Skip to content

Commit 9804a5a

Browse files
authored
Merge pull request #1543 from nextcloud/fix-slow-capabilities
Fix slow capabilities
2 parents 018441d + 05c493e commit 9804a5a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,14 @@ public function getOrCreateFolder(string $path, bool $create = true) : Folder {
183183
return $folder;
184184
}
185185

186-
public function getNotesFolderUserPath(string $userId): ?string {
187-
/** @psalm-suppress MissingDependency */
188-
$userFolder = $this->getRoot()->getUserFolder($userId);
186+
public function getNotesFolderUserPath(string $userId, bool $saveInitial = false): ?string {
189187
try {
190-
$nodesFolder = $this->getOrCreateNotesFolder($userId, false);
188+
$notesFolder = $this->settingsService->get($userId, 'notesPath', $saveInitial);
189+
return $notesFolder;
191190
} catch (NotesFolderException $e) {
192191
$this->util->logger->debug("Failed to get notes folder for user $userId: " . $e->getMessage());
193192
return null;
194193
}
195-
return $userFolder->getRelativePath($nodesFolder->getPath());
196194
}
197195

198196
public function getOrCreateNotesFolder(string $userId, bool $create = true) : Folder {

lib/Service/SettingsService.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public function set(string $uid, array $settings, bool $writeDefaults = false) :
112112
if ($value !== null && array_key_exists($name, $this->attrs)) {
113113
$settings[$name] = $value = $this->attrs[$name]['validate']($value);
114114
}
115+
if ($name === 'notesPath' && $value !== null) {
116+
continue;
117+
}
115118
$default = is_callable($this->attrs[$name]['default']) ? $this->attrs[$name]['default']($uid) : $this->attrs[$name]['default'];
116119
if (!$writeDefaults && (!array_key_exists($name, $this->attrs)
117120
|| $value === null
@@ -169,8 +172,8 @@ public function getAll(string $uid, $saveInitial = false) : \stdClass {
169172
/**
170173
* @throws \OCP\PreConditionNotMetException
171174
*/
172-
public function get(string $uid, string $name) : string {
173-
$settings = $this->getAll($uid);
175+
public function get(string $uid, string $name, bool $saveInitial = false) : string {
176+
$settings = $this->getAll($uid, $saveInitial);
174177
if (property_exists($settings, $name)) {
175178
return $settings->{$name};
176179
} else {

0 commit comments

Comments
 (0)