Merge branch 'master' of gitorious.org:owncloud/owncloud
Conflicts: apps/files_versions/lib/versions.php
This commit is contained in:
commit
b1c9785eb3
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
OCP\JSON::checkAppEnabled('files_versions');
|
OCP\JSON::checkAppEnabled('files_versions');
|
||||||
|
|
||||||
require_once('apps/files_versions/versions.php');
|
|
||||||
|
|
||||||
$userDirectory = "/".OCP\USER::getUser()."/files";
|
$userDirectory = "/".OCP\USER::getUser()."/files";
|
||||||
|
|
||||||
$file = $_GET['file'];
|
$file = $_GET['file'];
|
||||||
|
|
|
@ -75,6 +75,11 @@ class Storage {
|
||||||
*/
|
*/
|
||||||
public function store($filename) {
|
public function store($filename) {
|
||||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||||
|
|
||||||
|
$files_view = \OCP\Files::getStorage("files");
|
||||||
|
$users_view = \OCP\Files::getStorage("files_versions");
|
||||||
|
$users_view->chroot(\OCP\User::getUser().'/');
|
||||||
|
|
||||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||||
$pos = strpos($source, '/files', 1);
|
$pos = strpos($source, '/files', 1);
|
||||||
$uid = substr($source, 1, $pos - 1);
|
$uid = substr($source, 1, $pos - 1);
|
||||||
|
@ -86,8 +91,13 @@ class Storage {
|
||||||
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
|
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
|
||||||
Storage::init();
|
Storage::init();
|
||||||
|
|
||||||
|
//check if source file already exist as version to avoid recursions.
|
||||||
|
if ($users_view->file_exists($filename)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// check if filename is a directory
|
// check if filename is a directory
|
||||||
if(is_dir($filesfoldername.'/'.$filename)){
|
if($files_view->is_dir($filename)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +112,7 @@ class Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check filesize
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,10 +133,10 @@ class Storage {
|
||||||
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) mkdir($versionsFolderName.'/'.$info['dirname'],0700,true);
|
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) mkdir($versionsFolderName.'/'.$info['dirname'],0700,true);
|
||||||
|
|
||||||
// store a new version of a file
|
// 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
|
// expire old revisions if necessary
|
||||||
$this->expire($filename);
|
Storage::expire($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +144,7 @@ class Storage {
|
||||||
/**
|
/**
|
||||||
* rollback to an old version of a file.
|
* rollback to an old version of a file.
|
||||||
*/
|
*/
|
||||||
public function rollback( $filename, $revision ) {
|
public static function rollback($filename,$revision) {
|
||||||
|
|
||||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||||
|
@ -149,7 +159,7 @@ class Storage {
|
||||||
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
|
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
|
||||||
|
|
||||||
// rollback
|
// rollback
|
||||||
if ( copy( $versionsFolderName.'/'.$filename.'.v'.$revision, $filesfoldername.'/'.$filename ) ) {
|
if ( @copy($versionsFolderName.'/'.$filename.'.v'.$revision,$filesfoldername.'/'.$filename) ) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -271,7 +281,7 @@ class Storage {
|
||||||
/**
|
/**
|
||||||
* @brief Erase a file's versions which exceed the set quota
|
* @brief Erase a file's versions which exceed the set quota
|
||||||
*/
|
*/
|
||||||
public function expire( $filename ) {
|
public static function expire($filename) {
|
||||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||||
|
|
||||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||||
|
@ -295,7 +305,7 @@ class Storage {
|
||||||
|
|
||||||
foreach( $deleteItems as $de ) {
|
foreach( $deleteItems as $de ) {
|
||||||
|
|
||||||
$this->view->unlink( $versionsFolderName.'/'.$filename.'.v'.$de );
|
unlink( $versionsFolderName.'/'.$filename.'.v'.$de );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +337,7 @@ class Storage {
|
||||||
if(Storage::isversioned($rel_path)) {
|
if(Storage::isversioned($rel_path)) {
|
||||||
$versions = Storage::getVersions($rel_path);
|
$versions = Storage::getVersions($rel_path);
|
||||||
foreach ($versions as $v){
|
foreach ($versions as $v){
|
||||||
$this->view->unlink( $abs_path . $v['version'] );
|
unlink($abs_path . $v['version']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,7 @@ class OC_Filesystem{
|
||||||
if($path[0]!=='/'){
|
if($path[0]!=='/'){
|
||||||
$path='/'.$path;
|
$path='/'.$path;
|
||||||
}
|
}
|
||||||
|
$path=str_replace('//', '/',$path);
|
||||||
$foundMountPoint='';
|
$foundMountPoint='';
|
||||||
foreach(OC_Filesystem::$mounts as $mountpoint=>$storage){
|
foreach(OC_Filesystem::$mounts as $mountpoint=>$storage){
|
||||||
if($mountpoint==$path){
|
if($mountpoint==$path){
|
||||||
|
|
|
@ -276,7 +276,7 @@ class OC_FilesystemView {
|
||||||
}else{
|
}else{
|
||||||
$source=$this->fopen($path1,'r');
|
$source=$this->fopen($path1,'r');
|
||||||
$target=$this->fopen($path2,'w');
|
$target=$this->fopen($path2,'w');
|
||||||
$count=OC_Helper::streamCopy($data,$target);
|
$count=OC_Helper::streamCopy($source,$target);
|
||||||
$storage1=$this->getStorage($path1);
|
$storage1=$this->getStorage($path1);
|
||||||
$storage1->unlink($this->getInternalPath($path1));
|
$storage1->unlink($this->getInternalPath($path1));
|
||||||
$result=$count>0;
|
$result=$count>0;
|
||||||
|
@ -314,7 +314,7 @@ class OC_FilesystemView {
|
||||||
}else{
|
}else{
|
||||||
$source=$this->fopen($path1,'r');
|
$source=$this->fopen($path1,'r');
|
||||||
$target=$this->fopen($path2,'w');
|
$target=$this->fopen($path2,'w');
|
||||||
$count=OC_Helper::streamCopy($data,$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));
|
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){
|
if(!$exists){
|
||||||
|
|
Loading…
Reference in New Issue