diff options
author | Björn Schießle <bjoern@schiessle.org> | 2017-11-20 16:15:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 16:15:52 +0100 |
commit | f347e2e4a6cab71c35d58ff21692e23d7443db60 (patch) | |
tree | 878bd5f18958fdde2666d58b49a558a98bc209e9 /core | |
parent | bca165805ea8b27cc127ac71f140d8d0ed7f4edb (diff) | |
parent | 3e844d3a59cc571c93b6edcd80dce2cffd89072b (diff) | |
download | nextcloud-server-f347e2e4a6cab71c35d58ff21692e23d7443db60.tar.gz nextcloud-server-f347e2e4a6cab71c35d58ff21692e23d7443db60.zip |
Merge pull request #7047 from nextcloud/add-support-for-files-with-no-permissions
Add support for files with no permissions
Diffstat (limited to 'core')
-rw-r--r-- | core/js/files/client.js | 5 | ||||
-rw-r--r-- | core/js/js.js | 1 | ||||
-rw-r--r-- | core/js/tests/specs/files/clientSpec.js | 50 |
3 files changed, 23 insertions, 33 deletions
diff --git a/core/js/files/client.js b/core/js/files/client.js index e810381342a..fa3d795d412 100644 --- a/core/js/files/client.js +++ b/core/js/files/client.js @@ -320,7 +320,7 @@ } } - data.permissions = OC.PERMISSION_READ; + data.permissions = OC.PERMISSION_NONE; var permissionProp = props[Client.PROPERTY_PERMISSIONS]; if (!_.isUndefined(permissionProp)) { var permString = permissionProp || ''; @@ -333,6 +333,9 @@ case 'K': data.permissions |= OC.PERMISSION_CREATE; break; + case 'G': + data.permissions |= OC.PERMISSION_READ; + break; case 'W': case 'N': case 'V': diff --git a/core/js/js.js b/core/js/js.js index 730586713a0..9af80676d5e 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -60,6 +60,7 @@ function fileDownloadPath(dir, file) { /** @namespace */ var OCP = {}, OC = { + PERMISSION_NONE:0, PERMISSION_CREATE:4, PERMISSION_READ:1, PERMISSION_UPDATE:2, diff --git a/core/js/tests/specs/files/clientSpec.js b/core/js/tests/specs/files/clientSpec.js index d66c209bca5..6593372144a 100644 --- a/core/js/tests/specs/files/clientSpec.js +++ b/core/js/tests/specs/files/clientSpec.js @@ -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' }, [ @@ -640,14 +640,14 @@ describe('OC.Files.Client tests', function() { function testPermission(permission, isFile, expectedPermissions) { var promise = getFileInfoWithPermission(permission, isFile); - promise.then(function(result) { + promise.then(function(status, result) { expect(result.permissions).toEqual(expectedPermissions); }); } function testMountType(permission, isFile, expectedMountType) { var promise = getFileInfoWithPermission(permission, isFile); - promise.then(function(result) { + promise.then(function(status, result) { expect(result.mountType).toEqual(expectedMountType); }); } @@ -655,43 +655,29 @@ 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_CREATE | 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(testCase); - }); - }); - it('properly parses folder permissions', function() { - var testCases = [ - ['', false, OC.PERMISSION_READ], - ['C', false, OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE], - ['K', false, OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE], - ['W', false, OC.PERMISSION_READ | OC.PERMISSION_UPDATE], - ['D', false, OC.PERMISSION_READ | OC.PERMISSION_DELETE], - ['R', false, OC.PERMISSION_READ | OC.PERMISSION_SHARE], - ['CKWDR', false, OC.PERMISSION_ALL] - ]; - - _.each(testCases, function(testCase) { - return testPermission.apply(testCase); + return testPermission.apply(this, testCase); }); }); it('properly parses mount types', function() { var testCases = [ - ['CKWDR', false, null], + ['CKGWDR', false, null], ['M', false, 'external'], ['S', false, 'shared'], ['SM', false, 'shared'] ]; _.each(testCases, function(testCase) { - return testMountType.apply(testCase); + return testMountType.apply(this, testCase); }); }); }); |