openrat-webdav

git clone http://git.code.weiherhei.de/openrat-webdav.git
Log | Files | Refs

commit 9b6b0033765dddf8011e21301184e5ec83166062
parent 8982903bc4a103e6a2c882f09b34dc91d3f0a696
Author: Jan Dankert <develop@jandankert.de>
Date:   Wed,  6 Nov 2019 23:55:30 +0100

Fixes for uploading files.

Diffstat:
cms/CMS.class.php | 6+++---
dav/method/MKCOL.class.php | 5++---
dav/method/PUT.class.php | 15++++++++-------
3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/cms/CMS.class.php b/cms/CMS.class.php @@ -104,14 +104,14 @@ class CMS public function fileWrite($id,$value) { - $result = $this->call(CMS_WRITE,'file','save',array('id'=>$id,'value'=>$value) ); + $result = $this->call(CMS_WRITE,'file','save',array('id'=>$id,'file'=>$value) ); return $result; } - public function fileAdd($value) + public function fileAdd($parentid,$value) { - $result = $this->call(CMS_WRITE,'file','save',array('value'=>$value) ); + $result = $this->call(CMS_WRITE,'folder','createfile',array('id'=>$parentid,'file'=>$value) ); return $result; } diff --git a/dav/method/MKCOL.class.php b/dav/method/MKCOL.class.php @@ -15,7 +15,6 @@ class DAV_MKCOL extends DAV } elseif ( $this->readonly ) { - Logger::trace('hi'); $this->httpForbidden(); // Kein Schreibzugriff erlaubt } elseif ( $this->request->type == URIParser::PROJECT && ! $this->request->exists() ) @@ -37,8 +36,8 @@ class DAV_MKCOL extends DAV } else { - Logger::warn(''); - throw new InvalidArgumentException(); + Logger::warn('MKCOL failed'); + throw new InalidArgumentException('Unknown type'); } } diff --git a/dav/method/PUT.class.php b/dav/method/PUT.class.php @@ -22,10 +22,10 @@ class DAV_PUT extends DAV elseif ( strlen($this->data) > $this->maxFileSize*1000 ) { // Maximale Dateigroesse ueberschritten. - // Der Status 207 "Zuwenig Speicherplatz" passt nicht ganz, aber fast :) + // Der Status 507 "Zuwenig Speicherplatz" passt nicht ganz, aber fast :) $this->httpStatus('507 Insufficient Storage' ); } - elseif ( ! $this->request->objectid ) + elseif ( ! $this->request->exists() ) { // Neue Datei anlegen if ( !$this->create ) @@ -33,21 +33,22 @@ class DAV_PUT extends DAV Logger::warn('WEBDAV: Creation of files not allowed by configuration' ); $this->httpStatus('405 Not Allowed' ); } - - $this->client->fileAdd( $this->data ); + + $folderid = $this->request->folderid; + $this->client->fileAdd( $folderid,$this->data ); $this->httpStatus('201 Created'); return; } - elseif ( $this->request->objectid ) + elseif ( $this->request->exists() ) { // Bestehende Datei ueberschreiben. $id = $this->request->objectid; - $this->client->fileAdd( $id,$this->data ); + $this->client->fileWrite( $id,$this->data ); $this->httpStatus('204 No Content'); return; } - elseif ( $this->obj->isFolder ) + elseif ( $this->request->type == URIParser::FOLDER ) { Logger::error('PUT on folder is not supported, use PROPFIND. Lame client?' ); $this->httpMethodNotAllowed();