← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~mterry/duplicity/gio_child_for_display_name_0.7 into lp:duplicity/0.7-series

 

Michael Terry has proposed merging lp:~mterry/duplicity/gio_child_for_display_name_0.7 into lp:duplicity/0.7-series.

Requested reviews:
  duplicity-team (duplicity-team)

For more details, see:
https://code.launchpad.net/~mterry/duplicity/gio_child_for_display_name_0.7/+merge/329050

A minor improvement to my recent display_name patch for the GIO backend. Since we now get a list of display names from GIO, it only makes sense that we ask for new files with the get_child_for_display_name API.

I know of no bugs doing what we were doing (any file we request should be simple ASCII -- and this API is mostly for using utf8 strings instead of bytecode strings). But some backends, like google-drive: have vastly different concepts of name vs display name. The google-drive: backend currently accepts either in get_child(), but maybe one day it (or a similar bizarre backend) will be more pedantic.

So let's just use the more correct API now before it becomes a problem.
-- 
Your team duplicity-team is requested to review the proposed merge of lp:~mterry/duplicity/gio_child_for_display_name_0.7 into lp:duplicity/0.7-series.
=== modified file 'duplicity/backends/giobackend.py'
--- duplicity/backends/giobackend.py	2017-08-06 21:10:28 +0000
+++ duplicity/backends/giobackend.py	2017-08-15 15:53:00 +0000
@@ -141,12 +141,12 @@
     def _put(self, source_path, remote_filename):
         from gi.repository import Gio  # @UnresolvedImport
         source_file = Gio.File.new_for_path(source_path.name)
-        target_file = self.remote_file.get_child(remote_filename)
+        target_file = self.remote_file.get_child_for_display_name(remote_filename)
         self.__copy_file(source_file, target_file)
 
     def _get(self, filename, local_path):
         from gi.repository import Gio  # @UnresolvedImport
-        source_file = self.remote_file.get_child(filename)
+        source_file = self.remote_file.get_child_for_display_name(filename)
         target_file = Gio.File.new_for_path(local_path.name)
         self.__copy_file(source_file, target_file)
 
@@ -156,9 +156,7 @@
         # We grab display name, rather than file name because some backends
         # (e.g. google-drive:) use filesystem-specific IDs as file names and
         # only expose the "normal" name as display names. We need the display
-        # name, because we try to parse them. If the backend does this sort of
-        # trickery, it will accept both versions of the filename, so we
-        # shouldn't get into any trouble doing this.
+        # name, because we try to parse them.
         enum = self.remote_file.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
                                                    Gio.FileQueryInfoFlags.NONE,
                                                    None)
@@ -169,12 +167,12 @@
         return files
 
     def _delete(self, filename):
-        target_file = self.remote_file.get_child(filename)
+        target_file = self.remote_file.get_child_for_display_name(filename)
         target_file.delete(None)
 
     def _query(self, filename):
         from gi.repository import Gio  # @UnresolvedImport
-        target_file = self.remote_file.get_child(filename)
+        target_file = self.remote_file.get_child_for_display_name(filename)
         info = target_file.query_info(Gio.FILE_ATTRIBUTE_STANDARD_SIZE,
                                       Gio.FileQueryInfoFlags.NONE, None)
         return {'size': info.get_size()}


Follow ups