Skip to content

Commit

Permalink
add params for put interface
Browse files Browse the repository at this point in the history
for later usage like nextcloud/server#22019
  • Loading branch information
yrong authored and phil-davis committed Nov 17, 2021
1 parent 75e3e88 commit 6432caa
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/CalDAV/CalendarObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function get()
*
* @return string
*/
public function put($calendarData)
public function put($calendarData,$params=null)
{
if (is_resource($calendarData)) {
$calendarData = stream_get_contents($calendarData);
Expand Down
2 changes: 1 addition & 1 deletion lib/CalDAV/Schedule/SchedulingObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function get()
*
* @return string
*/
public function put($calendarData)
public function put($calendarData,$params=null)
{
throw new MethodNotAllowed('Updating scheduling objects is not supported');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/CardDAV/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function get()
*
* @return string|null
*/
public function put($cardData)
public function put($cardData,$params=null)
{
if (is_resource($cardData)) {
$cardData = stream_get_contents($cardData);
Expand Down
3 changes: 2 additions & 1 deletion lib/DAV/CorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ public function httpPut(RequestInterface $request, ResponseInterface $response)
{
$body = $request->getBodyAsStream();
$path = $request->getPath();
$params = (object) array('versioning' => $request->getHeader('versioning'));

// Intercepting Content-Range
if ($request->getHeader('Content-Range')) {
Expand Down Expand Up @@ -489,7 +490,7 @@ public function httpPut(RequestInterface $request, ResponseInterface $response)
if (!($node instanceof IFile)) {
throw new Exception\Conflict('PUT is not allowed on non-files.');
}
if (!$this->server->updateFile($path, $body, $etag)) {
if (!$this->server->updateFile($path, $body, $etag,$params)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/DAV/FS/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class File extends Node implements DAV\IFile
*
* @param resource $data
*/
public function put($data)
public function put($data,$params=null)
{
file_put_contents($this->path, $data);
clearstatcache(true, $this->path);
Expand Down
2 changes: 1 addition & 1 deletion lib/DAV/FSExt/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport
*
* @return string
*/
public function put($data)
public function put($data,$params=null)
{
file_put_contents($this->path, $data);
clearstatcache(true, $this->path);
Expand Down
2 changes: 1 addition & 1 deletion lib/DAV/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class File extends Node implements IFile
*
* @return string|null
*/
public function put($data)
public function put($data,$params=null)
{
throw new Exception\Forbidden('Permission denied to change data');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/DAV/IFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface IFile extends INode
*
* @return string|null
*/
public function put($data);
public function put($data,$params=null);

/**
* Returns the data.
Expand Down
5 changes: 2 additions & 3 deletions lib/DAV/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ public function createFile($uri, $data, &$etag = null)
*
* @return bool
*/
public function updateFile($uri, $data, &$etag = null)
public function updateFile($uri, $data, &$etag = null,$params)
{
$node = $this->tree->getNodeForPath($uri);

Expand All @@ -1133,8 +1133,7 @@ public function updateFile($uri, $data, &$etag = null)
if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) {
return false;
}

$etag = $node->put($data);
$etag = $node->put($data,$params);
if ($modified) {
$etag = null;
}
Expand Down

0 comments on commit 6432caa

Please sign in to comment.