summaryrefslogtreecommitdiffstats
path: root/lib/private/connector/sabre/file.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-10-08 11:26:49 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-10-08 11:26:49 +0200
commit0293d8e04f614c330be8aac7e968eec8469fb0e5 (patch)
treedc82d5f0c7e21fd93ea9f5a5d0180b9c8cde25dd /lib/private/connector/sabre/file.php
parent2123ef57d830abe24684b54f9819b75ab780834e (diff)
downloadnextcloud-server-0293d8e04f614c330be8aac7e968eec8469fb0e5.tar.gz
nextcloud-server-0293d8e04f614c330be8aac7e968eec8469fb0e5.zip
If a existing file in Shared/ with update permissions gets updated we need to write the .part file to a different place because we can't create new files in the Shared folder
Diffstat (limited to 'lib/private/connector/sabre/file.php')
-rw-r--r--lib/private/connector/sabre/file.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 12d7585884e..43e25de40c7 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -45,7 +45,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return string|null
*/
public function put($data) {
+
$fs = $this->getFS();
+
if ($fs->file_exists($this->path) &&
!$fs->isUpdatable($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
@@ -58,12 +60,14 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// chunked handling
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
+
list($path, $name) = \Sabre_DAV_URLUtil::splitPath($this->path);
$info = OC_FileChunking::decodeName($name);
if (empty($info)) {
throw new Sabre_DAV_Exception_NotImplemented();
}
+
$chunk_handler = new OC_FileChunking($info);
$chunk_handler->store($info['index'], $data);
if ($chunk_handler->isComplete()) {
@@ -78,6 +82,13 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// mark file as partial while uploading (ignored by the scanner)
$partpath = $this->path . '.part';
+ // if file is located in /Shared we write the part file to the users
+ // root folder because we can't create new files in /shared
+ // we extend the name with a random number to avoid overwriting a existing file
+ if (dirname($partpath) === 'Shared') {
+ $partpath = pathinfo($partpath, PATHINFO_FILENAME) . rand();
+ }
+
try {
$putOkay = $fs->file_put_contents($partpath, $data);
if ($putOkay === false) {