Parcourir la source

Fix webdav for davfs2

Guénaël Muller il y a 6 ans
Parent
révision
f2476d9462
1 fichiers modifiés avec 18 ajouts et 8 suppressions
  1. 18 8
      tracim/tracim/lib/webdav/sql_resources.py

+ 18 - 8
tracim/tracim/lib/webdav/sql_resources.py Voir le fichier

@@ -215,14 +215,24 @@ class Workspace(DAVCollection):
215 215
         if resource:
216 216
             content = resource.content
217 217
 
218
-        return FakeFileStream(
219
-            file_name=file_name,
220
-            content_api=self.content_api,
221
-            workspace=self.workspace,
222
-            content=content,
223
-            parent=self.content,
224
-            path=self.path + '/' + file_name
225
-        )
218
+        if not content:
219
+            # INFO - G.M - 21-03-2018 create new empty file and commit it.
220
+            new_empty_file = FakeFileStream(
221
+                file_name=file_name,
222
+                content_api=self.content_api,
223
+                workspace=self.workspace,
224
+                content=content,
225
+                parent=self.content,
226
+                path=path,
227
+            )
228
+            new_empty_file.close()
229
+
230
+        # INFO - G.M - 21-03-2018 - Obtain true davFile from provider
231
+        resource = self.provider.getResourceInst(path, self.environ)
232
+        if not resource:
233
+            raise DAVError(HTTP_FORBIDDEN)
234
+        content = resource.content
235
+        return File(path=path, content=content,environ=self.environ)
226 236
 
227 237
     def createCollection(self, label: str) -> 'Folder':
228 238
         """