From d875191777188bde61804452c55964842fceb083 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Sat, 5 May 2012 16:47:23 +0200
Subject: [PATCH] only emit the filesystem hooks once when creating a new file

---
 apps/files/ajax/newfile.php | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 2712b54f063..316eac0562d 100755
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -32,15 +32,16 @@ if($source){
 		OCP\JSON::error(array("data" => array( "message" => "Error while downloading ".$source. ' to '.$target )));
 		exit();
 	}
-}
-
-
-if(OC_Files::newFile($dir, $filename, 'file')) {
+}else{
 	if($content){
-		OC_Filesystem::file_put_contents($dir.'/'.$filename,$content);
+		if(OC_Filesystem::file_put_contents($dir.'/'.$filename,$content)){
+			OCP\JSON::success(array("data" => array('content'=>$content)));
+			exit();
+		}
+	}elseif(OC_Files::newFile($dir, $filename, 'file')){
+		OCP\JSON::success(array("data" => array('content'=>$content)));
+		exit();
 	}
-	OCP\JSON::success(array("data" => array('content'=>$content)));
-	exit();
 }
 
 
-- 
GitLab