Add support for copying files between shared folders, add check to fromTmpFile() to confirm path is writeable

This commit is contained in:
Michael Gapczynski 2011-07-13 15:27:16 -04:00
parent 5896e48755
commit 24e24f1b65
1 changed files with 18 additions and 9 deletions

View File

@ -355,10 +355,15 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE {
} }
public function copy($path1, $path2) { public function copy($path1, $path2) {
$source = $this->getSource($path1); if ($path2 == "" || $path2 == "/") {
if ($source) { // TODO Construct new shared item or should this not be allowed?
$storage = OC_FILESYSTEM::getStorage($source); } else {
return $storage->copy($this->getInternalPath($source), $path2); if ($this->is_writeable($path)) {
$tmpFile = $this->toTmpFile($path1);
return $this->fromTmpFile($tmpFile, $path2);
} else {
return false;
}
} }
} }
@ -378,11 +383,15 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE {
} }
} }
public function fromTmpFile($tmpPath, $path) { public function fromTmpFile($tmpFile, $path) {
$source = $this->getSource($tmpPath); if ($this->is_writeable($path)) {
if ($source) { $source = $this->getSource($path);
$storage = OC_FILESYSTEM::getStorage($source); if ($source) {
return $storage->fromTmpFile($this->getInternalPath($source), $path); $storage = OC_FILESYSTEM::getStorage($source);
return $storage->fromTmpFile($tmpFile, $this->getInternalPath($source));
}
} else {
return false;
} }
} }