From 148e4facfae0fc4ea0198212882920747014ecce Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 19 Sep 2012 20:59:57 +0200 Subject: [PATCH 1/2] Change files_versions namespace to OCA\Files_Versions --- apps/files_versions/ajax/getVersions.php | 2 +- apps/files_versions/ajax/rollbackVersion.php | 2 +- apps/files_versions/appinfo/app.php | 10 +++++----- apps/files_versions/history.php | 4 ++-- apps/files_versions/lib/hooks.php | 2 +- apps/files_versions/lib/versions.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 600e69cf79..53fc04625c 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -5,7 +5,7 @@ $userDirectory = "/".OCP\USER::getUser()."/files"; $source = $_GET['source']; $count = 5; //show the newest revisions -if( ($versions = OCA_Versions\Storage::getVersions( $source, $count)) ) { +if( ($versions = OCA\Files_Versions\Storage::getVersions( $source, $count)) ) { $versionsFormatted = array(); diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php index f2c211d9c1..dc5a59cb4a 100644 --- a/apps/files_versions/ajax/rollbackVersion.php +++ b/apps/files_versions/ajax/rollbackVersion.php @@ -8,7 +8,7 @@ $userDirectory = "/".OCP\USER::getUser()."/files"; $file = $_GET['file']; $revision=(int)$_GET['revision']; -if(OCA_Versions\Storage::rollback( $file, $revision )) { +if(OCA\Files_Versions\Storage::rollback( $file, $revision )) { OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); }else{ OCP\JSON::error(array("data" => array( "message" => "Could not revert:" . $file ))); diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index edd0a2f702..f7c6989ce2 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -1,8 +1,8 @@ assign( 'path', $path ); - $versions = new OCA_Versions\Storage(); + $versions = new OCA\Files_Versions\Storage(); // roll back to old version if button clicked if( isset( $_GET['revert'] ) ) { @@ -52,7 +52,7 @@ if ( isset( $_GET['path'] ) ) { // show the history only if there is something to show $count = 999; //show the newest revisions - if( ($versions = OCA_Versions\Storage::getVersions( $path, $count)) ) { + if( ($versions = OCA\Files_Versions\Storage::getVersions( $path, $count)) ) { $tmpl->assign( 'versions', array_reverse( $versions ) ); diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php index 5cefc53289..dc02c605c4 100644 --- a/apps/files_versions/lib/hooks.php +++ b/apps/files_versions/lib/hooks.php @@ -10,7 +10,7 @@ * This class contains all hooks. */ -namespace OCA_Versions; +namespace OCA\Files_Versions; class Hooks { diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 003d548d2b..1db0a8fef8 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -13,7 +13,7 @@ * A class to handle the versioning of files. */ -namespace OCA_Versions; +namespace OCA\Files_Versions; class Storage { From 3e7ca373ec75434755fa5c1a63a6b3b126ba4fb7 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 19 Sep 2012 21:26:24 +0200 Subject: [PATCH 2/2] Only calculate md5 of local file once --- apps/files_versions/lib/versions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 1db0a8fef8..ca7eb9e735 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -195,6 +195,7 @@ class Storage { $files_view = new \OC_FilesystemView('/'.$uid.'/files'); $local_file = $files_view->getLocalFile($filename); + $local_file_md5 = \md5_file( $local_file ); foreach( $matches as $ma ) { $parts = explode( '.v', $ma ); @@ -206,7 +207,7 @@ class Storage { $versions[$key]['size'] = $versions_fileview->filesize($filename.'.v'.$version); // if file with modified date exists, flag it in array as currently enabled version - ( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$key]['fileMatch'] = 1 : $versions[$key]['fileMatch'] = 0 ); + ( \md5_file( $ma ) == $local_file_md5 ? $versions[$key]['fileMatch'] = 1 : $versions[$key]['fileMatch'] = 0 ); }