From da892d69ab724354e1b3ee251e540ba306fffe44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= <schiessle@owncloud.com>
Date: Fri, 12 Jul 2013 13:25:37 +0200
Subject: [PATCH] if the file doesn't exists; create a new one. We use this to
 create new text files in the web interface

---
 apps/files_external/lib/webdav.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index c2fe7c67b5..4869322d87 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -234,7 +234,13 @@ class DAV extends \OC\Files\Storage\Common{
 			$mtime=time();
 		}
 		$path=$this->cleanPath($path);
-		$this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime));
+
+		// if file exists, update the mtime, else create a new empty file
+		if ($this->file_exists($path)) {
+			$this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime));
+		} else {
+			$this->file_put_contents($path, '');
+		}
 	}
 
 	public function getFile($path, $target) {
-- 
GitLab