Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show Files with read and download permissions #38369

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 10 additions & 0 deletions core/src/OC/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,14 @@ const Dialogs = {
self.$fileListHeader.find('[data-sort=' + self.filepicker.sortField + '] .sort-indicator').addClass('icon-triangle-s')
}

//Only show files with read and download permissions
var filteredFiles = function(files) {
return files.filter((file) => {
const downloadShareAttribute = file.shareAttributes.find((shareAttribute) => shareAttribute.key === 'download')
const downloadPermissions = downloadShareAttribute !== undefined ? downloadShareAttribute.enabled : true
return (file.permissions & OC.PERMISSION_READ) && downloadPermissions
})
}
// Wrap within a method because a promise cannot return multiple values
// But the client impleemntation still does it...
var getFolderContents = async function(dir) {
Expand All @@ -1150,10 +1158,12 @@ const Dialogs = {

try {
var files = await getFolderContents(dir)
files = filteredFiles(files)
} catch (error) {
// fallback to root if requested dir is non-existent
console.error('Requested path does not exists, falling back to root')
var files = await getFolderContents('/')
files = filteredFiles(files)
this.$filePicker.data('path', '/')
this._changeButtonsText(type, '')
}
Expand Down
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.