-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stable10] Let CopyPlugin fall back to default impl if no ICopySource #31805
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,12 @@ | |
|
||
/** | ||
* Class CopyPlugin - adds own implementation of the COPY method. | ||
* This is necessary because we don't want the target to be deleted before the move. | ||
* | ||
* Invokes ICopySource->copy() if the source and destination types match. | ||
* If the source doesn't implement ICopySource, fall back to the default behavior. | ||
* | ||
* Currently only used for versions. | ||
* This is necessary because we don't want the target to be deleted before the move. | ||
* Deleting the target will kill the versions which is the wrong behavior. | ||
* | ||
* @package OCA\DAV\DAV | ||
|
@@ -57,9 +61,6 @@ function initialize(Server $server) { | |
/** | ||
* WebDAV HTTP COPY method | ||
* | ||
* This method copies one uri to a different uri, and works much like the MOVE request | ||
* A lot of the actual request processing is done in getCopyMoveInfo | ||
* | ||
* @param RequestInterface $request | ||
* @param ResponseInterface $response | ||
* @return bool | ||
|
@@ -71,24 +72,20 @@ function httpCopy(RequestInterface $request, ResponseInterface $response) { | |
|
||
$path = $request->getPath(); | ||
|
||
$copyInfo = $this->server->getCopyAndMoveInfo($request); | ||
$sourceNode = $this->server->tree->getNodeForPath($path); | ||
if (!$sourceNode instanceof ICopySource) { | ||
return true; | ||
} | ||
|
||
$copyInfo = $this->server->getCopyAndMoveInfo($request); | ||
$destinationNode = $copyInfo['destinationNode']; | ||
if (!$copyInfo['destinationExists'] || !$destinationNode instanceof File || !$sourceNode instanceof IFile) { | ||
return true; | ||
} | ||
|
||
if (!$this->server->emit('beforeBind', [$copyInfo['destination']])) return false; | ||
|
||
$copySuccess = false; | ||
if ($sourceNode instanceof ICopySource) { | ||
$copySuccess = $sourceNode->copy($destinationNode->getFileInfo()->getPath()); | ||
} | ||
if (!$copySuccess) { | ||
$destinationNode->acquireLock(ILockingProvider::LOCK_SHARED); | ||
$destinationNode->put($sourceNode->get()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't it break sth? I guess this was introduced with some purpose @DeepDiver1975 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no - because the processing will fallback to the origninal implementation above. |
||
$destinationNode->releaseLock(ILockingProvider::LOCK_SHARED); | ||
} | ||
$sourceNode->copy($destinationNode->getFileInfo()->getPath()); | ||
|
||
$this->server->emit('afterBind', [$copyInfo['destination']]); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this fall back to put?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will fall back to whatever the old copy operation does, it is likely a put, yes, with more permission checks