diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index c37133cf32ccaae54548b4c148dff4a5a566099e..20611c61ec7a7b2ae9303279b6167a0798bd6534 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -61,7 +61,7 @@ class Storage {
 		}
 		return false;
 	}
-	
+
 	/**
 	 * write to the database how much space is in use for versions
 	 * 
@@ -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 4ed3234552ed5fc3dfc7a4465a43da731849a755..19f33ad64a2f3102700146aa2ac3e5866aa10061 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -245,7 +245,14 @@ class View {
 		if (!is_null($mtime) and !is_numeric($mtime)) {
 			$mtime = strtotime($mtime);
 		}
-		return $this->basicOperation('touch', $path, array('write'), $mtime);
+		
+		$hooks = array('touch');
+		
+		if (!$this->file_exists($path)) {
+			$hooks[] = 'write';
+		}
+		
+		return $this->basicOperation('touch', $path, $hooks, $mtime);
 	}
 
 	public function file_get_contents($path) {
@@ -596,6 +603,7 @@ class View {
 			if ($path == null) {
 				return false;
 			}
+
 			$run = $this->runHooks($hooks, $path);
 			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
 			if ($run and $storage) {