aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-07-31 15:51:11 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-08-01 14:17:48 +0200
commit270ec122e084a7f1d481d70a8bf03fd50032b89f (patch)
tree92b893eceed9baf33407435dc07708e65af957ad /apps/files/src
parent014fcb0131e5ae0ce47c4b493e2aaab50105fc14 (diff)
downloadnextcloud-server-270ec122e084a7f1d481d70a8bf03fd50032b89f.tar.gz
nextcloud-server-270ec122e084a7f1d481d70a8bf03fd50032b89f.zip
fix(files): Correctly create Nodes from WebDAV result in "recent"-view
The recent search works on a different remote URL so the source of the files were wrong, because the remote url was included twice in the source. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/src')
-rw-r--r--apps/files/src/services/Files.ts13
-rw-r--r--apps/files/src/services/Recent.ts14
2 files changed, 14 insertions, 13 deletions
diff --git a/apps/files/src/services/Files.ts b/apps/files/src/services/Files.ts
index 86d9f9b8e80..944c2d30678 100644
--- a/apps/files/src/services/Files.ts
+++ b/apps/files/src/services/Files.ts
@@ -2,11 +2,11 @@
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import type { ContentsWithRoot } from '@nextcloud/files'
+import type { ContentsWithRoot, File, Folder } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed } from 'webdav'
import { CancelablePromise } from 'cancelable-promise'
-import { File, Folder, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
+import { davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
import { client } from './WebdavClient.ts'
import logger from '../logger.ts'
@@ -14,14 +14,7 @@ import logger from '../logger.ts'
* Slim wrapper over `@nextcloud/files` `davResultToNode` to allow using the function with `Array.map`
* @param node The node returned by the webdav library
*/
-export const resultToNode = (node: FileStat): File | Folder => {
- // TODO remove this hack with nextcloud-files v3.7
- // just needed because of a bug in the webdav client
- if (node.props?.displayname !== undefined) {
- node.props.displayname = String(node.props.displayname)
- }
- return davResultToNode(node)
-}
+export const resultToNode = (node: FileStat): File | Folder => davResultToNode(node)
export const getContents = (path = '/'): CancelablePromise<ContentsWithRoot> => {
const controller = new AbortController()
diff --git a/apps/files/src/services/Recent.ts b/apps/files/src/services/Recent.ts
index c8cde136069..0a953087781 100644
--- a/apps/files/src/services/Recent.ts
+++ b/apps/files/src/services/Recent.ts
@@ -3,19 +3,27 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { ContentsWithRoot, Node } from '@nextcloud/files'
-import type { ResponseDataDetailed, SearchResult } from 'webdav'
+import type { FileStat, ResponseDataDetailed, SearchResult } from 'webdav'
import { getCurrentUser } from '@nextcloud/auth'
-import { Folder, Permission, davGetRecentSearch, davRootPath, davRemoteURL } from '@nextcloud/files'
+import { Folder, Permission, davGetRecentSearch, davRootPath, davRemoteURL, davResultToNode } from '@nextcloud/files'
import { CancelablePromise } from 'cancelable-promise'
import { useUserConfigStore } from '../store/userconfig.ts'
import { pinia } from '../store/index.ts'
import { client } from './WebdavClient.ts'
-import { resultToNode } from './Files.ts'
+import { getBaseUrl } from '@nextcloud/router'
const lastTwoWeeksTimestamp = Math.round((Date.now() / 1000) - (60 * 60 * 24 * 14))
/**
+ * Helper to map a WebDAV result to a Nextcloud node
+ * The search endpoint already includes the dav remote URL so we must not include it in the source
+ *
+ * @param stat the WebDAV result
+ */
+const resultToNode = (stat: FileStat) => davResultToNode(stat, davRootPath, getBaseUrl())
+
+/**
* Get recently changed nodes
*
* This takes the users preference about hidden files into account.