Skip to content

Commit b6f9356

Browse files
Merge pull request #50292 from nextcloud/fix/federated-share-opening
2 parents af8189f + f1631c0 commit b6f9356

File tree

8 files changed

+90
-37
lines changed

8 files changed

+90
-37
lines changed

apps/files/src/components/FilesListVirtual.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export default defineComponent({
330330
* @param fileId File to open
331331
*/
332332
handleOpenFile(fileId: number|null) {
333-
if (fileId === null || this.openFileId === fileId) {
333+
if (fileId === null) {
334334
return
335335
}
336336

apps/files_sharing/src/services/SharingService.spec.ts

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ describe('SharingService share to Node mapping', () => {
275275
tags: [TAG_FAVORITE],
276276
}
277277

278-
const remoteFile = {
278+
const remoteFileAccepted = {
279279
mimetype: 'text/markdown',
280280
mtime: 1688721600,
281281
permissions: 19,
@@ -294,6 +294,25 @@ describe('SharingService share to Node mapping', () => {
294294
accepted: true,
295295
}
296296

297+
const remoteFilePending = {
298+
mimetype: 'text/markdown',
299+
mtime: 1688721600,
300+
permissions: 19,
301+
type: 'file',
302+
file_id: 1234,
303+
id: 4,
304+
share_type: ShareType.User,
305+
parent: null,
306+
remote: 'http://exampe.com',
307+
remote_id: '12345',
308+
share_token: 'share-token',
309+
name: '/test.md',
310+
mountpoint: '/shares/test.md',
311+
owner: 'owner-uid',
312+
user: 'sharee-uid',
313+
accepted: false,
314+
}
315+
297316
const tempExternalFile = {
298317
id: 65,
299318
share_type: 0,
@@ -369,33 +388,64 @@ describe('SharingService share to Node mapping', () => {
369388
expect(folder.attributes.favorite).toBe(1)
370389
})
371390

372-
test('Remote file', async () => {
373-
axios.get.mockReturnValueOnce(Promise.resolve({
374-
data: {
375-
ocs: {
376-
data: [remoteFile],
391+
describe('Remote file', () => {
392+
test('Accepted', async () => {
393+
axios.get.mockReturnValueOnce(Promise.resolve({
394+
data: {
395+
ocs: {
396+
data: [remoteFileAccepted],
397+
},
377398
},
378-
},
379-
}))
380-
381-
const shares = await getContents(false, true, false, false)
382-
383-
expect(axios.get).toHaveBeenCalledTimes(1)
384-
expect(shares.contents).toHaveLength(1)
399+
}))
400+
401+
const shares = await getContents(false, true, false, false)
402+
403+
expect(axios.get).toHaveBeenCalledTimes(1)
404+
expect(shares.contents).toHaveLength(1)
405+
406+
const file = shares.contents[0] as File
407+
expect(file).toBeInstanceOf(File)
408+
expect(file.fileid).toBe(1234)
409+
expect(file.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/test.md')
410+
expect(file.owner).toBe('owner-uid')
411+
expect(file.mime).toBe('text/markdown')
412+
expect(file.mtime?.getTime()).toBe(remoteFileAccepted.mtime * 1000)
413+
// not available for remote shares
414+
expect(file.size).toBe(undefined)
415+
expect(file.permissions).toBe(19)
416+
expect(file.root).toBe('/files/test')
417+
expect(file.attributes).toBeInstanceOf(Object)
418+
expect(file.attributes.favorite).toBe(0)
419+
})
385420

386-
const file = shares.contents[0] as File
387-
expect(file).toBeInstanceOf(File)
388-
expect(file.fileid).toBe(1234)
389-
expect(file.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/test.md')
390-
expect(file.owner).toBe('owner-uid')
391-
expect(file.mime).toBe('text/markdown')
392-
expect(file.mtime?.getTime()).toBe(remoteFile.mtime * 1000)
393-
// not available for remote shares
394-
expect(file.size).toBe(undefined)
395-
expect(file.permissions).toBe(0)
396-
expect(file.root).toBe('/files/test')
397-
expect(file.attributes).toBeInstanceOf(Object)
398-
expect(file.attributes.favorite).toBe(0)
421+
test('Pending', async () => {
422+
axios.get.mockReturnValueOnce(Promise.resolve({
423+
data: {
424+
ocs: {
425+
data: [remoteFilePending],
426+
},
427+
},
428+
}))
429+
430+
const shares = await getContents(false, true, false, false)
431+
432+
expect(axios.get).toHaveBeenCalledTimes(1)
433+
expect(shares.contents).toHaveLength(1)
434+
435+
const file = shares.contents[0] as File
436+
expect(file).toBeInstanceOf(File)
437+
expect(file.fileid).toBe(1234)
438+
expect(file.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/test.md')
439+
expect(file.owner).toBe('owner-uid')
440+
expect(file.mime).toBe('text/markdown')
441+
expect(file.mtime?.getTime()).toBe(remoteFilePending.mtime * 1000)
442+
// not available for remote shares
443+
expect(file.size).toBe(undefined)
444+
expect(file.permissions).toBe(0)
445+
expect(file.root).toBe('/files/test')
446+
expect(file.attributes).toBeInstanceOf(Object)
447+
expect(file.attributes.favorite).toBe(0)
448+
})
399449
})
400450

401451
test('External temp file', async () => {

apps/files_sharing/src/services/SharingService.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
4040
ocsEntry.file_target = ocsEntry.name
4141
}
4242

43-
// Need to set permissions to NONE for federated shares
44-
ocsEntry.item_permissions = Permission.NONE
45-
ocsEntry.permissions = Permission.NONE
43+
// If the share is not accepted yet we don't know which permissions it will have
44+
if (!ocsEntry.accepted) {
45+
// Need to set permissions to NONE for federated shares
46+
ocsEntry.item_permissions = Permission.NONE
47+
ocsEntry.permissions = Permission.NONE
48+
}
4649

4750
ocsEntry.uid_owner = ocsEntry.owner
4851
// TODO: have the real display name stored somewhere

dist/18-18.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)