Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>('open', { default: true })

const {
storage = { backendOptions: {}, mountOptions: {}, type: isAdmin ? 'system' : 'personal' },
storage = { backendOptions: {}, mountOptions: { ...DEFAULT_MOUNT_OPTIONS }, type: isAdmin ? 'system' : 'personal' },
} = defineProps<{
storage?: Partial<IStorage>
}>()
Expand Down
14 changes: 12 additions & 2 deletions apps/files_external/src/store/storages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<IStorage[]>([])
const userStorages = ref<IStorage[]>([])
Expand Down Expand Up @@ -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
Expand Down
Loading