From fbd5bace0fc723c50263d546f7071fd053e22b9e Mon Sep 17 00:00:00 2001 From: "@suet-kei.chan" Date: Fri, 20 Nov 2026 17:51:35 +0100 Subject: [PATCH] fix: make sharing popup work on Nextcloud 35 - replace OC.Files.FileInfo, removed in Nextcloud 34, with an equivalent local normalisation; the sharing popup failed with "Cannot read properties of undefined (reading 'FileInfo')" - use showError instead of the removed OC.Notification - allow Nextcloud 35 in info.xml All changes stay compatible with Nextcloud 33. --- appinfo/info.xml | 2 +- src/components/SharingEntryLink.vue | 2 +- src/services/FileInfoService.js | 41 ++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index fa7a893..e8f81a9 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -12,6 +12,6 @@ customization https://github.com/nextmcloud/nmcsharing/issues - + diff --git a/src/components/SharingEntryLink.vue b/src/components/SharingEntryLink.vue index da478f2..5723c9b 100755 --- a/src/components/SharingEntryLink.vue +++ b/src/components/SharingEntryLink.vue @@ -644,7 +644,7 @@ export default { if (!this.checkShare(this.share)) { this.open = true - OC.Notification.showTemporary( + showError( t( 'files_sharing', 'Error, please enter proper password and/or expiration date', diff --git a/src/services/FileInfoService.js b/src/services/FileInfoService.js index 9970fae..b328ff4 100644 --- a/src/services/FileInfoService.js +++ b/src/services/FileInfoService.js @@ -1,5 +1,44 @@ import { getShareAttributes } from '../utils/ShareAttributes.js' +/** + * Same normalisation as the legacy OC.Files.FileInfo, which Nextcloud 34 removed. + * + * @param {object} data raw file info values + * @return {object} FileInfo + */ +function createLegacyFileInfo(data) { + const fileInfo = { + icon: null, + hasPreview: true, + shareAttributes: [], + quotaAvailableBytes: -1, + } + + for (const [key, value] of Object.entries(data)) { + if (typeof value !== 'function') { + fileInfo[key] = value + } + } + + if (fileInfo.id !== undefined) { + fileInfo.id = parseInt(data.id, 10) + } + + fileInfo.path = data.path || '' + + if (fileInfo.type === 'dir') { + fileInfo.mimetype = 'httpd/unix-directory' + } else { + fileInfo.mimetype = fileInfo.mimetype || 'application/octet-stream' + } + + if (!fileInfo.type) { + fileInfo.type = fileInfo.mimetype === 'httpd/unix-directory' ? 'dir' : 'file' + } + + return fileInfo +} + /** * Convert a Nextcloud FileNode into the legacy FileInfo shape * expected by the sharing components. @@ -67,7 +106,7 @@ export default function FileInfo(node) { } const fileInfo = - new OC.Files.FileInfo(rawFileInfo) + createLegacyFileInfo(rawFileInfo) /* * Compatibility helpers required by the existing