Skip to content

Commit f347e2e

Browse files
authored
Merge pull request #7047 from nextcloud/add-support-for-files-with-no-permissions
Add support for files with no permissions
2 parents bca1658 + 3e844d3 commit f347e2e

File tree

10 files changed

+61
-52
lines changed

10 files changed

+61
-52
lines changed

apps/dav/lib/Connector/Sabre/Node.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ public function getDavPermissions() {
300300
if ($this->info->isMounted()) {
301301
$p .= 'M';
302302
}
303+
if ($this->info->isReadable()) {
304+
$p .= 'G';
305+
}
303306
if ($this->info->isDeletable()) {
304307
$p .= 'D';
305308
}

apps/dav/tests/unit/Connector/Sabre/NodeTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@
4242
class NodeTest extends \Test\TestCase {
4343
public function davPermissionsProvider() {
4444
return array(
45-
array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RDNVW'),
46-
array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RDNVCK'),
47-
array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRDNVW'),
48-
array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMDNVW'),
49-
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SDNVW'),
50-
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RD'),
51-
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RNVW'),
52-
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RDNVW'),
53-
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RDNV'),
45+
array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RGDNVW'),
46+
array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RGDNVCK'),
47+
array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRGDNVW'),
48+
array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMGDNVW'),
49+
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SGDNVW'),
50+
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RGD'),
51+
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RGNVW'),
52+
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RGDNVW'),
53+
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'file', false, false, 'RDNVW'),
54+
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RGDNV'),
55+
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'dir', false, false, 'RDNVCK'),
5456
);
5557
}
5658

apps/files/js/fileactions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
}
236236
var filteredActions = {};
237237
$.each(actions, function (name, action) {
238-
if (action.permissions & permissions) {
238+
if ((action.permissions === OC.PERMISSION_NONE) || (action.permissions & permissions)) {
239239
filteredActions[name] = action;
240240
}
241241
});

apps/files/js/filelist.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@
408408
mime: 'all',
409409
order: -50,
410410
iconClass: 'icon-details',
411-
permissions: OC.PERMISSION_READ,
411+
permissions: OC.PERMISSION_NONE,
412412
actionHandler: function(fileName, context) {
413413
self._updateDetailsView(fileName);
414414
}
@@ -1161,6 +1161,11 @@
11611161
}
11621162
}
11631163

1164+
var permissions = fileData.permissions;
1165+
if (permissions === undefined || permissions === null) {
1166+
permissions = this.getDirectoryPermissions();
1167+
}
1168+
11641169
//containing tr
11651170
var tr = $('<tr></tr>').attr({
11661171
"data-id" : fileData.id,
@@ -1170,7 +1175,7 @@
11701175
"data-mime": mime,
11711176
"data-mtime": mtime,
11721177
"data-etag": fileData.etag,
1173-
"data-permissions": fileData.permissions || this.getDirectoryPermissions(),
1178+
"data-permissions": permissions,
11741179
"data-has-preview": fileData.hasPreview !== false
11751180
});
11761181

apps/files/js/tagsplugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
},
105105
mime: 'all',
106106
order: -100,
107-
permissions: OC.PERMISSION_READ,
107+
permissions: OC.PERMISSION_NONE,
108108
iconClass: function(fileName, context) {
109109
var $file = context.$file;
110110
var isFavorite = $file.data('favorite') === true;

apps/files/tests/js/filelistSpec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ describe('OCA.Files.FileList tests', function() {
297297
expect($tr.find('.filesize').text()).toEqual('Pending');
298298
expect($tr.find('.date').text()).not.toEqual('?');
299299
});
300+
it('generates file element with no permissions when permissions are explicitly none', function() {
301+
var fileData = {
302+
type: 'dir',
303+
name: 'testFolder',
304+
permissions: OC.PERMISSION_NONE
305+
};
306+
var $tr = fileList.add(fileData);
307+
expect($tr.attr('data-permissions')).toEqual('0');
308+
});
300309
it('generates file element with zero size when size is explicitly zero', function() {
301310
var fileData = {
302311
type: 'dir',

build/integration/features/sharing-v1-part3.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Feature: sharing
167167
And folder "/merge-test-outside-perms" of user "user0" is shared with user "user1" with permissions 31
168168
Then as "user1" gets properties of folder "/merge-test-outside-perms" with
169169
|{http://owncloud.org/ns}permissions|
170-
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
170+
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
171171
And as "user1" the folder "/merge-test-outside-perms (2)" does not exist
172172

173173
Scenario: Merging shares for recipient when shared from outside with two groups
@@ -197,7 +197,7 @@ Feature: sharing
197197
And folder "/merge-test-outside-twogroups-perms" of user "user0" is shared with group "group2" with permissions 31
198198
Then as "user1" gets properties of folder "/merge-test-outside-twogroups-perms" with
199199
|{http://owncloud.org/ns}permissions|
200-
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
200+
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
201201
And as "user1" the folder "/merge-test-outside-twogroups-perms (2)" does not exist
202202

203203
Scenario: Merging shares for recipient when shared from outside with two groups and member
@@ -214,7 +214,7 @@ Feature: sharing
214214
And folder "/merge-test-outside-twogroups-member-perms" of user "user0" is shared with user "user1" with permissions 1
215215
Then as "user1" gets properties of folder "/merge-test-outside-twogroups-member-perms" with
216216
|{http://owncloud.org/ns}permissions|
217-
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
217+
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
218218
And as "user1" the folder "/merge-test-outside-twogroups-member-perms (2)" does not exist
219219

220220
Scenario: Merging shares for recipient when shared from inside with group
@@ -253,7 +253,7 @@ Feature: sharing
253253
And folder "/merge-test-inside-twogroups-perms" of user "user0" is shared with group "group2"
254254
Then as "user0" gets properties of folder "/merge-test-inside-twogroups-perms" with
255255
|{http://owncloud.org/ns}permissions|
256-
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "RDNVCK"
256+
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "RGDNVCK"
257257
And as "user0" the folder "/merge-test-inside-twogroups-perms (2)" does not exist
258258
And as "user0" the folder "/merge-test-inside-twogroups-perms (3)" does not exist
259259

@@ -270,7 +270,7 @@ Feature: sharing
270270
And folder "/merge-test-outside-groups-renamebeforesecondshare" of user "user0" is shared with user "user1"
271271
Then as "user1" gets properties of folder "/merge-test-outside-groups-renamebeforesecondshare-renamed" with
272272
|{http://owncloud.org/ns}permissions|
273-
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
273+
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
274274
And as "user1" the folder "/merge-test-outside-groups-renamebeforesecondshare" does not exist
275275

276276
Scenario: Merging shares for recipient when shared from outside with user then group and recipient renames in between
@@ -287,7 +287,7 @@ Feature: sharing
287287
And folder "/merge-test-outside-groups-renamebeforesecondshare" of user "user0" is shared with group "group1"
288288
Then as "user1" gets properties of folder "/merge-test-outside-groups-renamebeforesecondshare-renamed" with
289289
|{http://owncloud.org/ns}permissions|
290-
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
290+
And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
291291
And as "user1" the folder "/merge-test-outside-groups-renamebeforesecondshare" does not exist
292292

293293
Scenario: Empting trashbin

core/js/files/client.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
}
321321
}
322322

323-
data.permissions = OC.PERMISSION_READ;
323+
data.permissions = OC.PERMISSION_NONE;
324324
var permissionProp = props[Client.PROPERTY_PERMISSIONS];
325325
if (!_.isUndefined(permissionProp)) {
326326
var permString = permissionProp || '';
@@ -333,6 +333,9 @@
333333
case 'K':
334334
data.permissions |= OC.PERMISSION_CREATE;
335335
break;
336+
case 'G':
337+
data.permissions |= OC.PERMISSION_READ;
338+
break;
336339
case 'W':
337340
case 'N':
338341
case 'V':

core/js/js.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function fileDownloadPath(dir, file) {
6060
/** @namespace */
6161
var OCP = {},
6262
OC = {
63+
PERMISSION_NONE:0,
6364
PERMISSION_CREATE:4,
6465
PERMISSION_READ:1,
6566
PERMISSION_UPDATE:2,

core/js/tests/specs/files/clientSpec.js

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe('OC.Files.Client tests', function() {
164164
'd:resourcetype': '<d:collection/>',
165165
'oc:id': '00000011oc2d13a6a068',
166166
'oc:fileid': '11',
167-
'oc:permissions': 'RDNVCK',
167+
'oc:permissions': 'GRDNVCK',
168168
'oc:size': '120'
169169
},
170170
[
@@ -196,7 +196,7 @@ describe('OC.Files.Client tests', function() {
196196
'd:resourcetype': '<d:collection/>',
197197
'oc:id': '00000015oc2d13a6a068',
198198
'oc:fileid': '15',
199-
'oc:permissions': 'RDNVCK',
199+
'oc:permissions': 'GRDNVCK',
200200
'oc:size': '100'
201201
},
202202
[
@@ -257,7 +257,7 @@ describe('OC.Files.Client tests', function() {
257257
expect(info.id).toEqual(51);
258258
expect(info.path).toEqual('/path/to space/文件夹');
259259
expect(info.name).toEqual('One.txt');
260-
expect(info.permissions).toEqual(27);
260+
expect(info.permissions).toEqual(26);
261261
expect(info.size).toEqual(250);
262262
expect(info.mtime).toEqual(1436535485000);
263263
expect(info.mimetype).toEqual('text/plain');
@@ -482,7 +482,7 @@ describe('OC.Files.Client tests', function() {
482482
'd:resourcetype': '<d:collection/>',
483483
'oc:id': '00000011oc2d13a6a068',
484484
'oc:fileid': '11',
485-
'oc:permissions': 'RDNVCK',
485+
'oc:permissions': 'GRDNVCK',
486486
'oc:size': '120'
487487
},
488488
[
@@ -549,7 +549,7 @@ describe('OC.Files.Client tests', function() {
549549
'd:resourcetype': '<d:collection/>',
550550
'oc:id': '00000011oc2d13a6a068',
551551
'oc:fileid': '11',
552-
'oc:permissions': 'RDNVCK',
552+
'oc:permissions': 'GRDNVCK',
553553
'oc:size': '120'
554554
},
555555
[
@@ -640,58 +640,44 @@ describe('OC.Files.Client tests', function() {
640640

641641
function testPermission(permission, isFile, expectedPermissions) {
642642
var promise = getFileInfoWithPermission(permission, isFile);
643-
promise.then(function(result) {
643+
promise.then(function(status, result) {
644644
expect(result.permissions).toEqual(expectedPermissions);
645645
});
646646
}
647647

648648
function testMountType(permission, isFile, expectedMountType) {
649649
var promise = getFileInfoWithPermission(permission, isFile);
650-
promise.then(function(result) {
650+
promise.then(function(status, result) {
651651
expect(result.mountType).toEqual(expectedMountType);
652652
});
653653
}
654654

655655
it('properly parses file permissions', function() {
656656
// permission, isFile, expectedPermissions
657657
var testCases = [
658-
['', true, OC.PERMISSION_READ],
659-
['C', true, OC.PERMISSION_READ | OC.PERMISSION_CREATE],
660-
['K', true, OC.PERMISSION_READ | OC.PERMISSION_CREATE],
661-
['W', true, OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE],
662-
['D', true, OC.PERMISSION_READ | OC.PERMISSION_DELETE],
663-
['R', true, OC.PERMISSION_READ | OC.PERMISSION_SHARE],
664-
['CKWDR', true, OC.PERMISSION_ALL]
658+
['', true, OC.PERMISSION_NONE],
659+
['C', true, OC.PERMISSION_CREATE],
660+
['K', true, OC.PERMISSION_CREATE],
661+
['G', true, OC.PERMISSION_READ],
662+
['W', true, OC.PERMISSION_UPDATE],
663+
['D', true, OC.PERMISSION_DELETE],
664+
['R', true, OC.PERMISSION_SHARE],
665+
['CKGWDR', true, OC.PERMISSION_ALL]
665666
];
666667
_.each(testCases, function(testCase) {
667-
return testPermission.apply(testCase);
668-
});
669-
});
670-
it('properly parses folder permissions', function() {
671-
var testCases = [
672-
['', false, OC.PERMISSION_READ],
673-
['C', false, OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE],
674-
['K', false, OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE],
675-
['W', false, OC.PERMISSION_READ | OC.PERMISSION_UPDATE],
676-
['D', false, OC.PERMISSION_READ | OC.PERMISSION_DELETE],
677-
['R', false, OC.PERMISSION_READ | OC.PERMISSION_SHARE],
678-
['CKWDR', false, OC.PERMISSION_ALL]
679-
];
680-
681-
_.each(testCases, function(testCase) {
682-
return testPermission.apply(testCase);
668+
return testPermission.apply(this, testCase);
683669
});
684670
});
685671
it('properly parses mount types', function() {
686672
var testCases = [
687-
['CKWDR', false, null],
673+
['CKGWDR', false, null],
688674
['M', false, 'external'],
689675
['S', false, 'shared'],
690676
['SM', false, 'shared']
691677
];
692678

693679
_.each(testCases, function(testCase) {
694-
return testMountType.apply(testCase);
680+
return testMountType.apply(this, testCase);
695681
});
696682
});
697683
});

0 commit comments

Comments
 (0)