summaryrefslogtreecommitdiffstats
path: root/lib/filesystemview.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-05 20:49:32 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-21 20:48:48 +0100
commite9af2185625f5012067cd5fe2ee04cee9828f11b (patch)
tree80f7a715f638f138c8916b274185c7752d348da1 /lib/filesystemview.php
parente2b49541760dabbdfce11bcc8063d31139b6caa3 (diff)
downloadnextcloud-server-e9af2185625f5012067cd5fe2ee04cee9828f11b.tar.gz
nextcloud-server-e9af2185625f5012067cd5fe2ee04cee9828f11b.zip
use streams instead of temporary files for cross-storage copy and rename
Diffstat (limited to 'lib/filesystemview.php')
-rw-r--r--lib/filesystemview.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index a78f3f652ad..27552d25f2b 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -179,9 +179,13 @@ class OC_FilesystemView {
if($storage=$this->getStorage($path1)){
$result=$storage->rename($this->getInternalPath($path1),$this->getInternalPath($path2));
}
- }elseif($storage1=$this->getStorage($path1) and $storage2=$this->getStorage($path2)){
- $tmpFile=$storage1->toTmpFile($this->getInternalPath($path1));
- $result=$storage2->fromTmpFile($tmpFile,$this->getInternalPath($path2));
+ }else{
+ $source=$this->fopen($path1,'r');
+ $target=$this->fopen($path2,'w');
+ while (!feof($source)){
+ fwrite($target,fread($source,8192));
+ }
+ $storage1=$this->getStorage($path1);
$storage1->unlink($this->getInternalPath($path1));
}
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, array( OC_Filesystem::signal_param_oldpath => $path1, OC_Filesystem::signal_param_newpath=>$path2));
@@ -207,9 +211,14 @@ class OC_FilesystemView {
if($storage=$this->getStorage($path1)){
$result=$storage->copy($this->getInternalPath($path1),$this->getInternalPath($path2));
}
- }elseif($storage1=$this->getStorage($path1) and $storage2=$this->getStorage($path2)){
- $tmpFile=$storage1->toTmpFile($this->getInternalPath($path1));
- $result=$storage2->fromTmpFile($tmpFile,$this->getInternalPath($path2));
+ }else{
+ $source=$this->fopen($path1,'r');
+ $target=$this->fopen($path2,'w');
+ if($target and $source){
+ while (!feof($source)){
+ fwrite($target,fread($source,8192));
+ }
+ }
}
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_copy, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2));
if(!$exists){