Skip to content

Commit

Permalink
fix(files): allow downloading folders within user root folders only
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Sep 18, 2023
1 parent 2845319 commit fb30aa0
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 41 deletions.
14 changes: 13 additions & 1 deletion apps/files/src/actions/downloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ export const action = new FileAction({
iconSvgInline: () => ArrowDownSvg,

enabled(nodes: Node[]) {
return nodes.length > 0 && nodes
if (nodes.length === 0) {
return false
}

// We can download direct dav files. But if we have
// some folders, we need to use the /apps/files/ajax/download.php
// endpoint, which only supports user root folder.
if (nodes.some(node => node.type === FileType.Folder)
&& !nodes.every(node => node.root?.startsWith('/files'))) {
return false
}

return nodes
.map(node => node.permissions)
.every(permission => (permission & Permission.READ) !== 0)
},
Expand Down
2 changes: 1 addition & 1 deletion apps/systemtags/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { getContents } from './services/systemtags.js'

const Navigation = getNavigation()
Navigation.register(new View({
id: 'systemtags',
id: 'tags',
name: t('systemtags', 'Tags'),
caption: t('systemtags', 'List of tags and their associated files and folders.'),

Expand Down
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/systemtags-init.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
* @copyright 2023 Christopher Ng <chrng8@gmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Christopher Ng <chrng8@gmail.com>
*
* @license AGPL-3.0-or-later
*
Expand All @@ -15,7 +14,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
Expand Down Expand Up @@ -44,27 +43,3 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* Copyright (c) 2016 Vincent Petry <pvince81@owncloud.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Vincent Petry <vincent@nextcloud.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
1 change: 1 addition & 0 deletions dist/systemtags-init.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions dist/systemtags-systemtags.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/systemtags-systemtags.js.map

This file was deleted.

0 comments on commit fb30aa0

Please sign in to comment.