From a8552c962b0612dff33890f1abde026f986d93b6 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 24 Jun 2026 16:38:24 +0200 Subject: [PATCH] fix(files_external): properly apply default mount options When parsing a backend object a missing `filesystem_check_changes` needs to be interpreted like in the server, so undefined means `Never`. Instead only new storages should get the recommend defaults per default. Signed-off-by: Ferdinand Thiessen --- .../AddExternalStorageDialog.vue | 3 ++- apps/files_external/src/store/storages.ts | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/files_external/src/components/AddExternalStorageDialog/AddExternalStorageDialog.vue b/apps/files_external/src/components/AddExternalStorageDialog/AddExternalStorageDialog.vue index eddb8caefffc5..01418d48b4838 100644 --- a/apps/files_external/src/components/AddExternalStorageDialog/AddExternalStorageDialog.vue +++ b/apps/files_external/src/components/AddExternalStorageDialog/AddExternalStorageDialog.vue @@ -27,12 +27,13 @@ import ApplicableEntities from './ApplicableEntities.vue' import AuthMechanismConfiguration from './AuthMechanismConfiguration.vue' import BackendConfiguration from './BackendConfiguration.vue' import MountOptions from './MountOptions.vue' +import { DEFAULT_MOUNT_OPTIONS } from '../../store/storages.ts' import { pruneUnusedAuthMechanismOptions } from '../../utils/externalStorageUtils.ts' const open = defineModel('open', { default: true }) const { - storage = { backendOptions: {}, mountOptions: {}, type: isAdmin ? 'system' : 'personal' }, + storage = { backendOptions: {}, mountOptions: { ...DEFAULT_MOUNT_OPTIONS }, type: isAdmin ? 'system' : 'personal' }, } = defineProps<{ storage?: Partial }>() diff --git a/apps/files_external/src/store/storages.ts b/apps/files_external/src/store/storages.ts index f2d7437c3eae0..e899d30d1fd63 100644 --- a/apps/files_external/src/store/storages.ts +++ b/apps/files_external/src/store/storages.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { IStorage } from '../types.ts' +import type { IMountOptions, IStorage } from '../types.ts' import axios from '@nextcloud/axios' import { loadState } from '@nextcloud/initial-state' @@ -15,6 +15,16 @@ import { MountOptionsCheckFilesystem } from '../types.ts' const { isAdmin } = loadState<{ isAdmin: boolean }>('files_external', 'settings') +/** The default mount options for NEW storages (not the defaults applied if a config is missing!) */ +export const DEFAULT_MOUNT_OPTIONS: IMountOptions = Object.freeze({ + encrypt: true, + previews: true, + filesystem_check_changes: MountOptionsCheckFilesystem.OncePerRequest, + enable_sharing: false, + encoding_compatibility: false, + readonly: false, +}) + export const useStorages = defineStore('files_external--storages', () => { const globalStorages = ref([]) const userStorages = ref([]) @@ -176,7 +186,7 @@ export function parseMountOptions(options: IStorage['mountOptions']) { mountOptions.enable_sharing = convertBooleanOptions(mountOptions.enable_sharing, false) mountOptions.filesystem_check_changes = typeof mountOptions.filesystem_check_changes === 'string' ? Number.parseInt(mountOptions.filesystem_check_changes) - : (mountOptions.filesystem_check_changes ?? MountOptionsCheckFilesystem.OncePerRequest) + : (mountOptions.filesystem_check_changes ?? MountOptionsCheckFilesystem.Never) // see default: https://github.com/nextcloud/server/blob/573104451bca64b4f1676933ac029583b4b69992/lib/private/Files/Storage/Common.php#L367 mountOptions.encoding_compatibility = convertBooleanOptions(mountOptions.encoding_compatibility, false) mountOptions.readonly = convertBooleanOptions(mountOptions.readonly, false) return mountOptions