Skip to content

Commit eea151f

Browse files
authored
Merge pull request #10565 from nextcloud/stable13-10348-fix-transfering-ownership-of-a-share-to-user-with-same-id-as-receiver
[stable13] Fix transfering ownership of a share to user with same id as receiver
2 parents 8d41d00 + 5da4e4d commit eea151f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

apps/files/lib/Command/TransferOwnership.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ private function restoreShares(OutputInterface $output) {
263263

264264
foreach($this->shares as $share) {
265265
try {
266-
if ($share->getSharedWith() === $this->destinationUser) {
266+
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
267+
$share->getSharedWith() === $this->destinationUser) {
267268
// Unmount the shares before deleting, so we don't try to get the storage later on.
268269
$shareMountPoint = $this->mountManager->find('/' . $this->destinationUser . '/files' . $share->getTarget());
269270
if ($shareMountPoint) {

build/integration/features/transfer-ownership.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ Feature: transfer-ownership
7272
And As an "user2"
7373
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"
7474

75+
Scenario: transfering ownership of file shares to user with the same id as the group
76+
Given user "user0" exists
77+
And user "test" exists
78+
And user "user2" exists
79+
And group "test" exists
80+
And user "user2" belongs to group "test"
81+
And User "user0" uploads file "data/textfile.txt" to "/somefile.txt"
82+
And file "/somefile.txt" of user "user0" is shared with group "test"
83+
When transfering ownership from "user0" to "test"
84+
And the command was successful
85+
And As an "user2"
86+
Then Downloaded content when downloading file "/somefile.txt" with range "bytes=0-6" should be "This is"
87+
7588
Scenario: transfering ownership does not transfer received shares
7689
Given user "user0" exists
7790
And user "user1" exists

0 commit comments

Comments
 (0)