summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2012-10-27 15:24:01 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-27 18:08:00 +0200
commit72aebe3aa3ce51ef47ef6005b528c4d296e208c6 (patch)
tree93061dd3143163257a719fbbd7dc29a4e12aafa8 /apps/files_versions
parent7891add28655c7f39b388ac0a889b246b23ad934 (diff)
downloadnextcloud-server-72aebe3aa3ce51ef47ef6005b528c4d296e208c6.tar.gz
nextcloud-server-72aebe3aa3ce51ef47ef6005b528c4d296e208c6.zip
fix broken paths in versions app
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/versions.php41
1 files changed, 19 insertions, 22 deletions
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 47e514d9d7e..e83310172af 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -58,10 +58,8 @@ class Storage {
public function store($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
-
- $userHome = \OC_User::getHome($uid);
- $files_view = new \OC\Files\View($userHome.'/files');
- $users_view = new \OC\Files\View($userHome);
+ $files_view = new \OC\Files\View('/'.\OCP\User::getUser() .'/files');
+ $users_view = new \OC\Files\View('/'.\OCP\User::getUser());
//check if source file already exist as version to avoid recursions.
// todo does this check work?
@@ -96,11 +94,12 @@ class Storage {
// check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval)
if ($uid == \OCP\User::getUser()) {
- $versions_fileview = new \OC\Files\View($userHome.'/files_versions');
- $versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
- $matches=glob($versionsFolderName.'/'.$filename.'.v*');
+ $versions_fileview = new \OC\Files\View('/'.\OCP\User::getUser().'/files_versions');
+ $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
+ $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('');
+ $matches=glob($versionsName.'.v*');
sort($matches);
- $parts=explode('.v', end($matches));
+ $parts=explode('.v',end($matches));
if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) {
return false;
}
@@ -110,7 +109,7 @@ class Storage {
// create all parent folders
$info=pathinfo($filename);
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) {
- mkdir($versionsFolderName.'/'.$info['dirname'],0750, true);
+ mkdir($versionsFolderName.'/'.$info['dirname'],0750,true);
}
// store a new version of a file
@@ -129,7 +128,7 @@ class Storage {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
- $users_view = new \OC\Files\View(\OC_User::getHome($uid));
+ $users_view = new \OC\Files\View('/'.\OCP\User::getUser());
// rollback
if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
@@ -152,12 +151,12 @@ class Storage {
public static function isversioned($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
- $versions_fileview = new \OC\Files\View(\OC_User::getHome($uid).'/files_versions');
+ $versions_fileview = new \OC\Files\View('/'.\OCP\User::getUser().'/files_versions');
- $versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
+ $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
// check for old versions
- $matches=glob($versionsFolderName.$filename.'.v*');
+ $matches=glob($versionsName.'.v*');
if(count($matches)>0) {
return true;
}else{
@@ -177,22 +176,20 @@ class Storage {
* @returns array
*/
public static function getVersions( $filename, $count = 0 ) {
-
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
list($uid, $filename) = self::getUidAndFilename($filename);
- $versions_fileview = new \OC\Files\View(\OC_User::getHome($uid).'/files_versions');
+ $versions_fileview = new \OC\Files\View('/'.\OCP\User::getUser().'/files_versions');
- $versionsFolderName = \OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
+ $versionsName = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
$versions = array();
-
// fetch for old versions
- $matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
+ $matches = glob( $versionsName.'.v*' );
sort( $matches );
$i = 0;
- $files_view = new \OC\Files\View(\OC_User::getHome($uid).'/files');
+ $files_view = new \OC\Files\View('/'.\OCP\User::getUser().'/files');
$local_file = $files_view->getLocalFile($filename);
foreach( $matches as $ma ) {
@@ -249,10 +246,10 @@ class Storage {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
- $versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
+ $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
// check for old versions
- $matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
+ $matches = glob( $versionsName.'.v*' );
if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) {
@@ -263,7 +260,7 @@ class Storage {
foreach( $deleteItems as $de ) {
- unlink( $versionsFolderName.'/'.$filename.'.v'.$de );
+ unlink( $versionsName.'.v'.$de );
}
}