From 8d26400cb5427763b0562da8799bea52f4eae21e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= <schiessle@owncloud.com>
Date: Fri, 8 Mar 2013 11:27:25 +0100
Subject: [PATCH] remove some debug output; move code to the right function

---
 apps/files_versions/lib/hooks.php    | 6 ------
 apps/files_versions/lib/versions.php | 8 ++++++++
 lib/files/view.php                   | 2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php
index 6e81286052..7891b20e92 100644
--- a/apps/files_versions/lib/hooks.php
+++ b/apps/files_versions/lib/hooks.php
@@ -21,12 +21,6 @@ class Hooks {
 
 		if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
 			$path = $params[\OC\Files\Filesystem::signal_param_path];
-			$pos = strrpos($path, '.part');
-			if ($pos) {
-				error_log("old path: $path");
-				$path = substr($path, 0, $pos);
-				error_log("new path: $path");
-			}
 			if($path<>'') {
 				Storage::store($path);
 			}
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 79b16f2586..20611c61ec 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -82,6 +82,14 @@ class Storage {
 	 */
 	public static function store($filename) {
 		if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
+			
+			// if the file gets streamed we need to remove the .part extension
+			// to get the right target
+			$ext = pathinfo($filename, PATHINFO_EXTENSION);
+			if ($ext === 'part') {
+				$filename = substr($filename, 0, strlen($filename)-5);
+			}
+			
 			list($uid, $filename) = self::getUidAndFilename($filename);
 
 			$files_view = new \OC\Files\View('/'.$uid .'/files');
diff --git a/lib/files/view.php b/lib/files/view.php
index 59339ff207..fe753342b6 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -603,7 +603,7 @@ class View {
 			if ($path == null) {
 				return false;
 			}
-			foreach ($hooks as $h) if ($h == "write") error_log("write triggered by $operation for $path");
+
 			$run = $this->runHooks($hooks, $path);
 			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
 			if ($run and $storage) {
-- 
GitLab