Skip to content

Commit

Permalink
Fix failure of shares which are already moved with transfer-ownership
Browse files Browse the repository at this point in the history
If the folder and files inside the folder are already moved
by the command, and if there is a public link inside the folder
then during the restore share operation the command throws
exception. This fix tries to check if the file/folder is already
moved. If so then there is no need to do call updateShare.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
  • Loading branch information
sharidas authored and gitmate-bot committed Jan 30, 2018
1 parent 883df49 commit 612fd8a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/files/lib/Command/TransferOwnership.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ private function restoreShares(OutputInterface $output) {
if ($share->getSharedBy() === $this->sourceUser) {
$share->setSharedBy($this->destinationUser);
}
/*
* If the share is already moved then updateShare would cause exception
* This can happen if the folder is shared and file(s) inside the folder
* has shares, for example public link
*/
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$sharePath = ltrim($share->getNode()->getPath(), '/');
if (strpos($sharePath, $this->finalTarget) !== false) {
//The share is already moved
continue;
}
}

$this->shareManager->updateShare($share);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/features/transfer-ownership.feature
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ Feature: transfer-ownership
And as an "user2"
Then downloaded content when downloading file "/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transferring ownership of folder shares which has public link
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And user "user0" created a folder "/test"
And user "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And folder "/test" of user "user0" is shared with user "user2" with permissions 31
And as an "user1"
And creating a share with
| path | /test/somefile.txt |
| shareType | 3 |
When transferring ownership of path "test" from "user0" to "user1"
And the command was successful
And as an "user2"
Then downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transferring ownership of folder shared with third user
Given user "user0" exists
Expand Down

0 comments on commit 612fd8a

Please sign in to comment.