fix: Remove duplicate propfind call

This also was an XHR call which is not going through the end to end encryption proxy

Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
Louis Chemineau 2025-01-13 14:54:18 +01:00
parent 0f2dcfd0f1
commit b1bc793940
No known key found for this signature in database
3 changed files with 37 additions and 32 deletions

View file

@ -1,30 +0,0 @@
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import axios from '@nextcloud/axios'
import { davGetDefaultPropfind } from '@nextcloud/files'
/**
* @param {any} url -
*/
export default async function(url) {
const response = await axios({
method: 'PROPFIND',
url,
data: davGetDefaultPropfind(),
})
// TODO: create new parser or use cdav-lib when available
const file = OC.Files.getClient()._client.parseMultiStatus(response.data)
// TODO: create new parser or use cdav-lib when available
const fileInfo = OC.Files.getClient()._parseFileInfo(file[0])
// TODO remove when no more legacy backbone is used
fileInfo.get = (key) => fileInfo[key]
fileInfo.isDirectory = () => fileInfo.mimetype === 'httpd/unix-directory'
fileInfo.canEdit = () => Boolean(fileInfo.permissions & OC.PERMISSION_UPDATE)
return fileInfo
}

View file

@ -0,0 +1,35 @@
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/* eslint-disable jsdoc/require-jsdoc */
import type { Node } from '@nextcloud/files'
export default function(node: Node) {
const fileInfo = new OC.Files.FileInfo({
id: node.fileid,
path: node.dirname,
name: node.basename,
mtime: node.mtime?.getTime(),
etag: node.attributes.etag,
size: node.size,
hasPreview: node.attributes.hasPreview,
isEncrypted: node.attributes.isEncrypted === 1,
isFavourited: node.attributes.favorite === 1,
mimetype: node.mime,
permissions: node.permissions,
mountType: node.attributes['mount-type'],
sharePermissions: node.attributes['share-permissions'],
shareAttributes: JSON.parse(node.attributes['share-attributes']),
type: node.type === 'file' ? 'file' : 'dir',
})
// TODO remove when no more legacy backbone is used
fileInfo.get = (key) => fileInfo[key]
fileInfo.isDirectory = () => fileInfo.mimetype === 'httpd/unix-directory'
fileInfo.canEdit = () => Boolean(fileInfo.permissions & OC.PERMISSION_UPDATE)
return fileInfo
}

View file

@ -487,10 +487,10 @@ export default {
this.loading = true
try {
this.fileInfo = await FileInfo(this.davPath)
this.node = await fetchNode({ path: this.file })
this.fileInfo = FileInfo(this.node)
// adding this as fallback because other apps expect it
this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')
this.node = await fetchNode({ path: (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/') })
// DEPRECATED legacy views
// TODO: remove