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>
pull/46918/head
Ferdinand Thiessen 2024-07-31 15:51:11 +07:00
parent 014fcb0131
commit 270ec122e0
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
2 changed files with 14 additions and 13 deletions

@ -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()

@ -3,18 +3,26 @@
* 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
*