Set read permission for files based on the data returned by the server

Now that the permissions returned by the server specify whether a file
is readable or not the frontend no longer needs to assume that every
file is readable.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2017-11-02 17:08:00 +01:00
parent ec375b3d86
commit 3e844d3a59
2 changed files with 18 additions and 14 deletions

View File

@ -319,7 +319,7 @@
}
}
data.permissions = OC.PERMISSION_READ;
data.permissions = OC.PERMISSION_NONE;
var permissionProp = props[Client.PROPERTY_PERMISSIONS];
if (!_.isUndefined(permissionProp)) {
var permString = permissionProp || '';
@ -332,6 +332,9 @@
case 'K':
data.permissions |= OC.PERMISSION_CREATE;
break;
case 'G':
data.permissions |= OC.PERMISSION_READ;
break;
case 'W':
case 'N':
case 'V':

View File

@ -164,7 +164,7 @@ describe('OC.Files.Client tests', function() {
'd:resourcetype': '<d:collection/>',
'oc:id': '00000011oc2d13a6a068',
'oc:fileid': '11',
'oc:permissions': 'RDNVCK',
'oc:permissions': 'GRDNVCK',
'oc:size': '120'
},
[
@ -196,7 +196,7 @@ describe('OC.Files.Client tests', function() {
'd:resourcetype': '<d:collection/>',
'oc:id': '00000015oc2d13a6a068',
'oc:fileid': '15',
'oc:permissions': 'RDNVCK',
'oc:permissions': 'GRDNVCK',
'oc:size': '100'
},
[
@ -257,7 +257,7 @@ describe('OC.Files.Client tests', function() {
expect(info.id).toEqual(51);
expect(info.path).toEqual('/path/to space/文件夹');
expect(info.name).toEqual('One.txt');
expect(info.permissions).toEqual(27);
expect(info.permissions).toEqual(26);
expect(info.size).toEqual(250);
expect(info.mtime).toEqual(1436535485000);
expect(info.mimetype).toEqual('text/plain');
@ -482,7 +482,7 @@ describe('OC.Files.Client tests', function() {
'd:resourcetype': '<d:collection/>',
'oc:id': '00000011oc2d13a6a068',
'oc:fileid': '11',
'oc:permissions': 'RDNVCK',
'oc:permissions': 'GRDNVCK',
'oc:size': '120'
},
[
@ -549,7 +549,7 @@ describe('OC.Files.Client tests', function() {
'd:resourcetype': '<d:collection/>',
'oc:id': '00000011oc2d13a6a068',
'oc:fileid': '11',
'oc:permissions': 'RDNVCK',
'oc:permissions': 'GRDNVCK',
'oc:size': '120'
},
[
@ -655,13 +655,14 @@ describe('OC.Files.Client tests', function() {
it('properly parses file permissions', function() {
// permission, isFile, expectedPermissions
var testCases = [
['', true, OC.PERMISSION_READ],
['C', true, OC.PERMISSION_READ | OC.PERMISSION_CREATE],
['K', true, OC.PERMISSION_READ | OC.PERMISSION_CREATE],
['W', true, OC.PERMISSION_READ | OC.PERMISSION_UPDATE],
['D', true, OC.PERMISSION_READ | OC.PERMISSION_DELETE],
['R', true, OC.PERMISSION_READ | OC.PERMISSION_SHARE],
['CKWDR', true, OC.PERMISSION_ALL]
['', true, OC.PERMISSION_NONE],
['C', true, OC.PERMISSION_CREATE],
['K', true, OC.PERMISSION_CREATE],
['G', true, OC.PERMISSION_READ],
['W', true, OC.PERMISSION_UPDATE],
['D', true, OC.PERMISSION_DELETE],
['R', true, OC.PERMISSION_SHARE],
['CKGWDR', true, OC.PERMISSION_ALL]
];
_.each(testCases, function(testCase) {
return testPermission.apply(this, testCase);
@ -669,7 +670,7 @@ describe('OC.Files.Client tests', function() {
});
it('properly parses mount types', function() {
var testCases = [
['CKWDR', false, null],
['CKGWDR', false, null],
['M', false, 'external'],
['S', false, 'shared'],
['SM', false, 'shared']