ソースを参照

Merge pull request #558 from inkhey/fix/557/Fix_webdav_for_davfs2

Bastien Sevajol 6 年 前
コミット
7f783ff0ff
No account linked to committer's email
共有1 個のファイルを変更した20 個の追加9 個の削除を含む
  1. 20 9
      tracim/tracim/lib/webdav/sql_resources.py

+ 20 - 9
tracim/tracim/lib/webdav/sql_resources.py ファイルの表示

@@ -24,7 +24,9 @@ from tracim.model.data import ContentType
24 24
 from tracim.lib.webdav.design import designThread, designPage
25 25
 
26 26
 from wsgidav import compat
27
-from wsgidav.dav_error import DAVError, HTTP_FORBIDDEN
27
+from wsgidav.dav_error import DAVError
28
+from wsgidav.dav_error import HTTP_FORBIDDEN
29
+from wsgidav.dav_error import HTTP_NOT_FOUND
28 30
 from wsgidav.dav_provider import DAVCollection, DAVNonCollection
29 31
 from wsgidav.dav_provider import _DAVResource
30 32
 from tracim.lib.webdav.utils import normpath
@@ -224,15 +226,24 @@ class Workspace(DAVCollection):
224 226
         if self._subfolder_regex.match(dirname(path)):
225 227
             raise DAVError(HTTP_FORBIDDEN)
226 228
 
229
+        if not content:
230
+            # INFO - G.M - 21-03-2018 create new empty file and commit it.
231
+            new_empty_file = FakeFileStream(
232
+                file_name=file_name,
233
+                content_api=self.content_api,
234
+                workspace=self.workspace,
235
+                content=content,
236
+                parent=self.content,
237
+                path=path,
238
+            )
239
+            new_empty_file.close()
227 240
 
228
-        return FakeFileStream(
229
-            file_name=file_name,
230
-            content_api=self.content_api,
231
-            workspace=self.workspace,
232
-            content=content,
233
-            parent=self.content,
234
-            path=self.path + '/' + file_name
235
-        )
241
+        # INFO - G.M - 21-03-2018 - Obtain true davFile from provider
242
+        resource = self.provider.getResourceInst(path, self.environ)
243
+        if not resource:
244
+            raise DAVError(HTTP_NOT_FOUND)
245
+        content = resource.content
246
+        return File(path=path, content=content, environ=self.environ)
236 247
 
237 248
     def createCollection(self, label: str) -> 'Folder':
238 249
         """