mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix(files_sharing): Normalize dir type to folder for federated shares
The backend returns type 'dir' for folders (from FileInfo::TYPE_FOLDER), but the frontend expects 'folder'. This mismatch caused federated shared folders to display incorrectly as files in the "Shared with you" view. Signed-off-by: nfebe <fenn25.fn@gmail.com>
This commit is contained in:
parent
f892437210
commit
13df65850e
2 changed files with 51 additions and 1 deletions
|
|
@ -313,6 +313,25 @@ describe('SharingService share to Node mapping', () => {
|
|||
accepted: false,
|
||||
}
|
||||
|
||||
const remoteFolderAccepted = {
|
||||
mimetype: 'httpd/unix-directory',
|
||||
mtime: 1688721600,
|
||||
permissions: 31,
|
||||
type: 'dir',
|
||||
file_id: 5678,
|
||||
id: 5,
|
||||
share_type: ShareType.User,
|
||||
parent: null,
|
||||
remote: 'http://example.com',
|
||||
remote_id: '12346',
|
||||
share_token: 'share-token-folder',
|
||||
name: '/testfolder',
|
||||
mountpoint: '/shares/testfolder',
|
||||
owner: 'owner-uid',
|
||||
user: 'sharee-uid',
|
||||
accepted: true,
|
||||
}
|
||||
|
||||
const tempExternalFile = {
|
||||
id: 65,
|
||||
share_type: 0,
|
||||
|
|
@ -457,6 +476,36 @@ describe('SharingService share to Node mapping', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Remote folder', () => {
|
||||
test('Accepted with type dir', async () => {
|
||||
axios.get.mockReturnValueOnce(Promise.resolve({
|
||||
data: {
|
||||
ocs: {
|
||||
data: [remoteFolderAccepted],
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
const shares = await getContents(false, true, false, false)
|
||||
|
||||
expect(axios.get).toHaveBeenCalledTimes(1)
|
||||
expect(shares.contents).toHaveLength(1)
|
||||
|
||||
const folder = shares.contents[0] as Folder
|
||||
expect(folder).toBeInstanceOf(Folder)
|
||||
expect(folder.fileid).toBe(5678)
|
||||
expect(folder.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/testfolder')
|
||||
expect(folder.owner).toBe('owner-uid')
|
||||
expect(folder.mime).toBe('httpd/unix-directory')
|
||||
expect(folder.mtime?.getTime()).toBe(remoteFolderAccepted.mtime * 1000)
|
||||
expect(folder.size).toBe(undefined)
|
||||
expect(folder.permissions).toBe(31)
|
||||
expect(folder.root).toBe('/files/test')
|
||||
expect(folder.attributes).toBeInstanceOf(Object)
|
||||
expect(folder.attributes.favorite).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
test('External temp file', async () => {
|
||||
axios.get.mockReturnValueOnce(Promise.resolve({
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ async function ocsEntryToNode(ocsEntry: any): Promise<Folder | File | null> {
|
|||
// This won't catch files without an extension, but this is the best we can do
|
||||
ocsEntry.mimetype = mime.getType(ocsEntry.name)
|
||||
}
|
||||
ocsEntry.item_type = ocsEntry.type || (ocsEntry.mimetype ? 'file' : 'folder')
|
||||
const type = ocsEntry.type === 'dir' ? 'folder' : ocsEntry.type
|
||||
ocsEntry.item_type = type || (ocsEntry.mimetype ? 'file' : 'folder')
|
||||
|
||||
// different naming for remote shares
|
||||
ocsEntry.item_mtime = ocsEntry.mtime
|
||||
|
|
|
|||
Loading…
Reference in a new issue