Fix WebDAV uploading of partial shared files

This commit is contained in:
Michael Gapczynski 2013-02-23 15:32:59 -05:00
parent 09a2730f57
commit b6a21cc4b5
1 changed files with 46 additions and 27 deletions

View File

@ -45,10 +45,20 @@ class Shared extends \OC\Files\Storage\Common {
*/
private function getFile($target) {
if (!isset($this->files[$target])) {
// 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;
}
return $this->files[$target];
@ -275,6 +285,14 @@ class Shared extends \OC\Files\Storage\Common {
}
public function rename($path1, $path2) {
// 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);
@ -306,6 +324,7 @@ class Shared extends \OC\Files\Storage\Common {
}
}
}
}
return false;
}