diff options
Diffstat (limited to 'apps/files/src/services')
-rw-r--r-- | apps/files/src/services/Favorites.ts | 29 | ||||
-rw-r--r-- | apps/files/src/services/Files.ts | 2 | ||||
-rw-r--r-- | apps/files/src/services/Recent.ts | 29 |
3 files changed, 3 insertions, 57 deletions
diff --git a/apps/files/src/services/Favorites.ts b/apps/files/src/services/Favorites.ts index c993ef57d33..633ba718560 100644 --- a/apps/files/src/services/Favorites.ts +++ b/apps/files/src/services/Favorites.ts @@ -28,6 +28,7 @@ import { getCurrentUser } from '@nextcloud/auth' import { getClient, rootPath } from './WebdavClient' import { getDavNameSpaces, getDavProperties, getDefaultPropfind } from './DavProperties' +import { resultToNode } from './Files' const client = getClient() @@ -47,34 +48,6 @@ interface ResponseProps extends DAVResultResponseProps { size: number, } -const resultToNode = function(node: FileStat): File | Folder { - const props = node.props as ResponseProps - const permissions = davParsePermissions(props?.permissions) - const owner = getCurrentUser()?.uid as string - - const nodeData = { - id: props?.fileid as number || 0, - source: generateRemoteUrl('dav' + rootPath + node.filename), - mtime: new Date(node.lastmod), - mime: node.mime as string, - size: props?.size as number || 0, - permissions, - owner, - root: rootPath, - attributes: { - ...node, - ...props, - hasPreview: props?.['has-preview'], - }, - } - - delete nodeData.attributes.props - - return node.type === 'file' - ? new File(nodeData) - : new Folder(nodeData) -} - export const getContents = async (path = '/'): Promise<ContentsWithRoot> => { const propfindPayload = getDefaultPropfind() diff --git a/apps/files/src/services/Files.ts b/apps/files/src/services/Files.ts index d392dbb7751..fba65ac44ae 100644 --- a/apps/files/src/services/Files.ts +++ b/apps/files/src/services/Files.ts @@ -40,7 +40,7 @@ interface ResponseProps extends DAVResultResponseProps { size: number, } -const resultToNode = function(node: FileStat): File | Folder { +export const resultToNode = function(node: FileStat): File | Folder { const props = node.props as ResponseProps const permissions = davParsePermissions(props?.permissions) const owner = getCurrentUser()?.uid as string diff --git a/apps/files/src/services/Recent.ts b/apps/files/src/services/Recent.ts index cec604ba855..7a585d28fc5 100644 --- a/apps/files/src/services/Recent.ts +++ b/apps/files/src/services/Recent.ts @@ -28,6 +28,7 @@ import { getCurrentUser } from '@nextcloud/auth' import { getClient, rootPath } from './WebdavClient' import { getDavNameSpaces, getDavProperties } from './DavProperties' +import { resultToNode } from './Files' const client = getClient(generateRemoteUrl('dav')) @@ -94,34 +95,6 @@ interface ResponseProps extends DAVResultResponseProps { size: number, } -const resultToNode = function(node: FileStat): File | Folder { - const props = node.props as ResponseProps - const permissions = davParsePermissions(props?.permissions) - const owner = getCurrentUser()?.uid as string - - const nodeData = { - id: props?.fileid as number || 0, - source: generateRemoteUrl('dav' + node.filename), - mtime: new Date(node.lastmod), - mime: node.mime as string, - size: props?.size as number || 0, - permissions, - owner, - root: rootPath, - attributes: { - ...node, - ...props, - hasPreview: props?.['has-preview'], - }, - } - - delete nodeData.attributes.props - - return node.type === 'file' - ? new File(nodeData) - : new Folder(nodeData) -} - export const getContents = async (path = '/'): Promise<ContentsWithRoot> => { const contentsResponse = await client.getDirectoryContents(path, { details: true, |