]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not repeat JSON success code.
authorAndreas Fischer <bantu@owncloud.com>
Thu, 8 Aug 2013 19:27:59 +0000 (21:27 +0200)
committerAndreas Fischer <bantu@owncloud.com>
Thu, 8 Aug 2013 20:14:21 +0000 (22:14 +0200)
apps/files/ajax/newfile.php

index 8ee4888b34de6769de9cf23c406f1f60b991b7a9..22598ee78e150fe6caa88af9d5c3e87937ecd4ad 100644 (file)
@@ -76,14 +76,14 @@ if($source) {
        $eventSource->close();
        exit();
 } else {
+       $success = false;
        if($content) {
-               if(\OC\Files\Filesystem::file_put_contents($target, $content)) {
-                       $meta = \OC\Files\Filesystem::getFileInfo($target);
-                       $id = $meta['fileid'];
-                       OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
-                       exit();
-               }
-       }elseif(\OC\Files\Filesystem::touch($target)) {
+               $success = \OC\Files\Filesystem::file_put_contents($target, $content);
+       } else {
+               $success = \OC\Files\Filesystem::touch($target);
+       }
+
+       if($success) {
                $meta = \OC\Files\Filesystem::getFileInfo($target);
                $id = $meta['fileid'];
                OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id, 'mime' => $meta['mimetype'])));
@@ -91,5 +91,4 @@ if($source) {
        }
 }
 
-
 OCP\JSON::error(array("data" => array( "message" => "Error when creating the file" )));