Parcourir la source

Do not return error when file copy is not necessary + log

Guénaël Muller il y a 6 ans
Parent
révision
c9d575647d
1 fichiers modifiés avec 16 ajouts et 2 suppressions
  1. 16 2
      tracim/tracim/lib/webdav/__init__.py

+ 16 - 2
tracim/tracim/lib/webdav/__init__.py Voir le fichier

@@ -6,6 +6,7 @@ from wsgidav import compat
6 6
 
7 7
 from tracim.lib.content import ContentApi
8 8
 from tracim.lib.utils import SameValueError
9
+from tracim.lib.base import logger
9 10
 from tracim.model import new_revision
10 11
 from tracim.model.data import ActionDescription
11 12
 from tracim.model.data import ContentType
@@ -105,10 +106,23 @@ class FakeFileStream(object):
105 106
                 self.update_file()
106 107
             transaction.commit()
107 108
         except SameValueError:
109
+            # INFO - G.M - 21-03-2018 - Do nothing, file as not change.
110
+            msg = 'File {filename} modified through webdav did not change, transaction aborted.'  # nopep8
111
+            logger.debug(
112
+                self,
113
+                msg.format(filename=self._file_name)
114
+            )
108 115
             transaction.abort()
109 116
             transaction.begin()
110
-            raise DAVError(HTTP_NOT_MODIFIED)
111
-        except ValueError:
117
+        except ValueError as e:
118
+            msg = 'File {filename} modified through webdav can\'t be updated: {exception}'  # nopep8
119
+            logger.debug(
120
+                self,
121
+                msg.format(
122
+                    filename=self._file_name,
123
+                    e=e.__str__,
124
+                )
125
+            )
112 126
             transaction.abort()
113 127
             transaction.begin()
114 128
             raise DAVError(HTTP_FORBIDDEN)