*/
public static function store($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
+ $files_view = \OCP\Files::getStorage("files");\r
+ $users_view = \OCP\Files::getStorage("files_versions");\r
+ $users_view->chroot(\OCP\User::getUser().'/');
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
$pos = strpos($source, '/files', 1);
$uid = substr($source, 1, $pos - 1);
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
Storage::init();
+ //check if source file already exist as version to avoid recursions.\r
+ if ($users_view->file_exists($filename)) {\r
+ return false;\r
+ }
+
// check if filename is a directory
- if(is_dir($filesfoldername.'/'.$filename)){
+ if($files_view->is_dir($filename)){
return false;
}
}
// check filesize
- if(filesize($filesfoldername.'/'.$filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){
+ if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){
return false;
}
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) mkdir($versionsFolderName.'/'.$info['dirname'],0700,true);
// store a new version of a file
- copy($filesfoldername.'/'.$filename,$versionsFolderName.'/'.$filename.'.v'.time());
+ $users_view->copy('files'.$filename, 'versions'.$filename.'.v'.time());
// expire old revisions if necessary
Storage::expire($filename);
}else{
$source=$this->fopen($path1,'r');
$target=$this->fopen($path2,'w');
- $count=OC_Helper::streamCopy($source,$target);
+ $result=OC_Helper::streamCopy($source,$target);
}
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){