Skip to content

Commit

Permalink
fix(settings) Prevent undefined related errors for encryption
Browse files Browse the repository at this point in the history
`Object.entries([])` would return an empty array, that leads to the `find`
return undefined.

`encryptionReady` and `encryptionEnabled` also returns undefined when no
encryption module is available or functional (I guess).

Signed-off-by: nfebe <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Nov 11, 2024
1 parent 14273a2 commit 35222b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion apps/files/src/utils/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function isDownloadable(node: Node): boolean {
if ((node.permissions & Permission.READ) === 0) {
return false
}
console.log('Node dataaaa', node)

// If the mount type is a share, ensure it got download permissions.
if (node.attributes['share-attributes']) {
Expand Down
1 change: 0 additions & 1 deletion apps/files_sharing/src/services/SharingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
mtime = new Date((ocsEntry.stime) * 1000)
}

console.log("WONDERRRRS", ocsEntry?.attributes)
return new Node({
id: fileid,
source,
Expand Down
22 changes: 15 additions & 7 deletions apps/settings/src/components/Encryption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:description="t('settings', 'Server-side encryption makes it possible to encrypt files which are uploaded to this server. This comes with limitations like a performance penalty, so enable this only if needed.')"
:doc-url="encryptionAdminDoc">
<NcCheckboxRadioSwitch :checked="encryptionEnabled || shouldDisplayWarning"
:disabled="encryptionEnabled"
type="switch"
@update:checked="displayWarning">
{{ t('settings', 'Enable server-side encryption') }}
Expand Down Expand Up @@ -88,26 +89,33 @@ export default {
},
data() {
const encryptionModules = loadState('settings', 'encryption-modules')
let defaultCheckedModule = ''
if (encryptionModules instanceof Array && encryptionModules.length > 0) {
const defaultModule = Object.entries(encryptionModules).find((module) => module[1].default)
if (defaultModule) {
defaultCheckedModule = foundModule[0]
}
} else {
logger.debug('No encryption module loaded or enabled')
}
return {
encryptionReady: loadState('settings', 'encryption-ready'),
encryptionEnabled: loadState('settings', 'encryption-enabled'),
encryptionReady: loadState('settings', 'encryption-ready', false),
encryptionEnabled: loadState('settings', 'encryption-enabled', false),
externalBackendsEnabled: loadState('settings', 'external-backends-enabled'),
encryptionAdminDoc: loadState('settings', 'encryption-admin-doc'),
encryptionModules,
shouldDisplayWarning: false,
migrating: false,
defaultCheckedModule: Object.entries(encryptionModules).find((module) => module[1].default)[0],
defaultCheckedModule,
}
},
methods: {
displayWarning() {
console.log("IS READY: " + this.encryptionReady)
console.log("ENCRYPTION Enabled: " + this.encryptionEnabled)
if (!this.encryptionEnabled) {
this.shouldDisplayWarning = !this.shouldDisplayWarning
} else {
// this.encryptionEnabled = false
// this.shouldDisplayWarning = false
this.encryptionEnabled = false
this.shouldDisplayWarning = false
}
},
async update(key, value) {
Expand Down

0 comments on commit 35222b8

Please sign in to comment.