mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
24 lines
753 B
TypeScript
24 lines
753 B
TypeScript
import type { Node } from '@nextcloud/files'
|
|
/**
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
import type { FileStat, ResponseDataDetailed } from 'webdav'
|
|
|
|
import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav'
|
|
|
|
export const client = getClient()
|
|
|
|
/**
|
|
* Fetches a node from the given path
|
|
*
|
|
* @param path - The path to fetch the node from
|
|
*/
|
|
export async function fetchNode(path: string): Promise<Node> {
|
|
const propfindPayload = getDefaultPropfind()
|
|
const result = await client.stat(`${getRootPath()}${path}`, {
|
|
details: true,
|
|
data: propfindPayload,
|
|
}) as ResponseDataDetailed<FileStat>
|
|
return resultToNode(result.data)
|
|
}
|