Fix WebDAV uploading of partial shared files
This commit is contained in:
parent
09a2730f57
commit
b6a21cc4b5
|
@ -45,9 +45,19 @@ class Shared extends \OC\Files\Storage\Common {
|
||||||
*/
|
*/
|
||||||
private function getFile($target) {
|
private function getFile($target) {
|
||||||
if (!isset($this->files[$target])) {
|
if (!isset($this->files[$target])) {
|
||||||
$source = \OC_Share_Backend_File::getSource($target);
|
// Check for partial files
|
||||||
if ($source) {
|
if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
|
||||||
$source['path'] = '/'.$source['uid_owner'].'/'.$source['path'];
|
$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;
|
$this->files[$target] = $source;
|
||||||
}
|
}
|
||||||
|
@ -275,34 +285,43 @@ class Shared extends \OC\Files\Storage\Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rename($path1, $path2) {
|
public function rename($path1, $path2) {
|
||||||
// Renaming/moving is only allowed within shared folders
|
// Check for partial files
|
||||||
$pos1 = strpos($path1, '/', 1);
|
if (pathinfo($path1, PATHINFO_EXTENSION) === 'part') {
|
||||||
$pos2 = strpos($path2, '/', 1);
|
if ($oldSource = $this->getSourcePath($path1)) {
|
||||||
if ($pos1 !== false && $pos2 !== false && ($oldSource = $this->getSourcePath($path1))) {
|
list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
|
||||||
$newSource = $this->getSourcePath(dirname($path2)).'/'.basename($path2);
|
$newInternalPath = substr($oldInternalPath, 0, -5);
|
||||||
if (dirname($path1) == dirname($path2)) {
|
return $storage->rename($oldInternalPath, $newInternalPath);
|
||||||
// Rename the file if UPDATE permission is granted
|
}
|
||||||
if ($this->isUpdatable($path1)) {
|
} else {
|
||||||
list($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
|
// Renaming/moving is only allowed within shared folders
|
||||||
list( , $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
|
$pos1 = strpos($path1, '/', 1);
|
||||||
return $storage->rename($oldInternalPath, $newInternalPath);
|
$pos2 = strpos($path2, '/', 1);
|
||||||
}
|
if ($pos1 !== false && $pos2 !== false && ($oldSource = $this->getSourcePath($path1))) {
|
||||||
} else {
|
$newSource = $this->getSourcePath(dirname($path2)).'/'.basename($path2);
|
||||||
// Move the file if DELETE and CREATE permissions are granted
|
if (dirname($path1) == dirname($path2)) {
|
||||||
if ($this->isDeletable($path1) && $this->isCreatable(dirname($path2))) {
|
// Rename the file if UPDATE permission is granted
|
||||||
// Get the root shared folder
|
if ($this->isUpdatable($path1)) {
|
||||||
$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($storage, $oldInternalPath) = \OC\Files\Filesystem::resolvePath($oldSource);
|
||||||
list( , $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
|
list( , $newInternalPath) = \OC\Files\Filesystem::resolvePath($newSource);
|
||||||
return $storage->rename($oldInternalPath, $newInternalPath);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue