Browse Source

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

Guénaël Muller 6 years ago
parent
commit
c9d575647d
1 changed files with 16 additions and 2 deletions
  1. 16 2
      tracim/tracim/lib/webdav/__init__.py

+ 16 - 2
tracim/tracim/lib/webdav/__init__.py View File

6
 
6
 
7
 from tracim.lib.content import ContentApi
7
 from tracim.lib.content import ContentApi
8
 from tracim.lib.utils import SameValueError
8
 from tracim.lib.utils import SameValueError
9
+from tracim.lib.base import logger
9
 from tracim.model import new_revision
10
 from tracim.model import new_revision
10
 from tracim.model.data import ActionDescription
11
 from tracim.model.data import ActionDescription
11
 from tracim.model.data import ContentType
12
 from tracim.model.data import ContentType
105
                 self.update_file()
106
                 self.update_file()
106
             transaction.commit()
107
             transaction.commit()
107
         except SameValueError:
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
             transaction.abort()
115
             transaction.abort()
109
             transaction.begin()
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
             transaction.abort()
126
             transaction.abort()
113
             transaction.begin()
127
             transaction.begin()
114
             raise DAVError(HTTP_FORBIDDEN)
128
             raise DAVError(HTTP_FORBIDDEN)