aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-02-23 15:32:59 -0500
committerMichael Gapczynski <mtgap@owncloud.com>2013-02-23 15:32:59 -0500
commitb6a21cc4b5f060863e1dbfa9d090b8baeed02b59 (patch)
treece56dca2c551208774de63452d2d059915eab78c /apps
parent09a2730f571c08945bfb90342c6cab9f7941e856 (diff)
downloadnextcloud-server-b6a21cc4b5f060863e1dbfa9d090b8baeed02b59.tar.gz
nextcloud-server-b6a21cc4b5f060863e1dbfa9d090b8baeed02b59.zip
Fix WebDAV uploading of partial shared files
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/sharedstorage.php73
1 files changed, 46 insertions, 27 deletions
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 65812b7e2fd..d0ee371c0b1 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -45,9 +45,19 @@ class Shared extends \OC\Files\Storage\Common {
*/
private function getFile($target) {
if (!isset($this->files[$target])) {
- $source = \OC_Share_Backend_File::getSource($target);
- if ($source) {
- $source['path'] = '/'.$source['uid_owner'].'/'.$source['path'];
+ // Check for partial files
+ if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
+ $source = \OC_Share_Backend_File::getSource(substr($target, 0, -5));
+ if ($source) {
+ $source['path'] = '/'.$source['uid_owner'].'/'.$source['path'].'.part';
+ // All partial files have delete permission
+ $source['permissions'] |= \OCP\PERMISSION_DELETE;
+ }
+ } else {
+ $source = \OC_Share_Backend_File::getSource($target);
+ if ($source) {
+ $source['path'] = '/'.$source['uid_owner'].'/'.$source['path'];
+ }
}
$this->files[$target] = $source;
}
@@ -275,34 +285,43 @@ class Shared extends \OC\Files\Storage\Common {
}
public function rename($path1, $path2) {
- // Renaming/moving is only allowed within shared folders
- $pos1 = strpos($path1, '/', 1);
- $pos2 = strpos($path2, '/', 1);
- if ($pos1 !== false && $pos2 !== false && ($oldSource = $this->getSourcePath($path1))) {
- $newSource = $this->getSourcePath(dirname($path2)).'/'.basename($path2);
- if (dirname($path1) == dirname($path2)) {
- // Rename the file if UPDATE permission is granted
- if ($this->isUpdatable($path1)) {
- list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
- list( , $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
- return $storage->rename($oldInternalPath, $newInternalPath);
- }
- } else {
- // Move the file if DELETE and CREATE permissions are granted
- if ($this->isDeletable($path1) && $this->isCreatable(dirname($path2))) {
- // Get the root shared folder
- $folder1 = substr($path1, 0, $pos1);
- $folder2 = substr($path2, 0, $pos2);
- // Copy and unlink the file if it exists in a different shared folder
- if ($folder1 != $folder2) {
- if ($this->copy($path1, $path2)) {
- return $this->unlink($path1);
- }
- } else {
+ // Check for partial files
+ if (pathinfo($path1, PATHINFO_EXTENSION) === 'part') {
+ if ($oldSource = $this->getSourcePath($path1)) {
+ list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
+ $newInternalPath = substr($oldInternalPath, 0, -5);
+ return $storage->rename($oldInternalPath, $newInternalPath);
+ }
+ } else {
+ // Renaming/moving is only allowed within shared folders
+ $pos1 = strpos($path1, '/', 1);
+ $pos2 = strpos($path2, '/', 1);
+ if ($pos1 !== false && $pos2 !== false && ($oldSource = $this->getSourcePath($path1))) {
+ $newSource = $this->getSourcePath(dirname($path2)).'/'.basename($path2);
+ if (dirname($path1) == dirname($path2)) {
+ // Rename the file if UPDATE permission is granted
+ if ($this->isUpdatable($path1)) {
list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
list( , $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
return $storage->rename($oldInternalPath, $newInternalPath);
}
+ } else {
+ // Move the file if DELETE and CREATE permissions are granted
+ if ($this->isDeletable($path1) && $this->isCreatable(dirname($path2))) {
+ // Get the root shared folder
+ $folder1 = substr($path1, 0, $pos1);
+ $folder2 = substr($path2, 0, $pos2);
+ // Copy and unlink the file if it exists in a different shared folder
+ if ($folder1 != $folder2) {
+ if ($this->copy($path1, $path2)) {
+ return $this->unlink($path1);
+ }
+ } else {
+ list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
+ list( , $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
+ return $storage->rename($oldInternalPath, $newInternalPath);
+ }
+ }
}
}
}