Browse Source

WebDav: fix File rename

Bastien Sevajol (Algoo) 8 years ago
parent
commit
afd74a039c
1 changed files with 8 additions and 11 deletions
  1. 8 11
      tracim/tracim/lib/webdav/sql_resources.py

+ 8 - 11
tracim/tracim/lib/webdav/sql_resources.py View File

948
 
948
 
949
     def move_file(self, destpath):
949
     def move_file(self, destpath):
950
 
950
 
951
-        workspace = self.provider.get_workspace_from_path(
952
-            normpath(destpath),
953
-            WorkspaceApi(self.user)
954
-        )
955
-
956
-        parent = self.provider.get_parent_from_path(
957
-            normpath(destpath),
958
-            self.content_api,
959
-            workspace
960
-        )
951
+        workspace = self.content.workspace
952
+        parent = self.content.parent
961
 
953
 
962
         with new_revision(self.content):
954
         with new_revision(self.content):
963
             if basename(destpath) != self.getDisplayName():
955
             if basename(destpath) != self.getDisplayName():
956
+                new_given_file_name = transform_to_bdd(basename(destpath))
957
+                new_file_name, new_file_extension = \
958
+                    os.path.splitext(new_given_file_name)
959
+
964
                 self.content_api.update_content(
960
                 self.content_api.update_content(
965
                     self.content,
961
                     self.content,
966
-                    transform_to_bdd(basename(destpath)),
962
+                    new_file_name,
967
                 )
963
                 )
964
+                self.content.file_extension = new_file_extension
968
                 self.content_api.save(self.content)
965
                 self.content_api.save(self.content)
969
             else:
966
             else:
970
                 self.content_api.move(
967
                 self.content_api.move(