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

Proposed by Michael Terry
Status: Merged
Merged at revision: 1308
Proposed branch: lp:~mterry/duplicity/gio_child_for_display_name_0.7
Merge into: lp:~duplicity-team/duplicity/0.7-series
Diff against target: 44 lines (+5/-7)
1 file modified
duplicity/backends/giobackend.py (+5/-7)
To merge this branch: bzr merge lp:~mterry/duplicity/gio_child_for_display_name_0.7
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+329050@code.launchpad.net

Description of the change

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.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
141 def _put(self, source_path, remote_filename):141 def _put(self, source_path, remote_filename):
142 from gi.repository import Gio # @UnresolvedImport142 from gi.repository import Gio # @UnresolvedImport
143 source_file = Gio.File.new_for_path(source_path.name)143 source_file = Gio.File.new_for_path(source_path.name)
144 target_file = self.remote_file.get_child(remote_filename)144 target_file = self.remote_file.get_child_for_display_name(remote_filename)
145 self.__copy_file(source_file, target_file)145 self.__copy_file(source_file, target_file)
146146
147 def _get(self, filename, local_path):147 def _get(self, filename, local_path):
148 from gi.repository import Gio # @UnresolvedImport148 from gi.repository import Gio # @UnresolvedImport
149 source_file = self.remote_file.get_child(filename)149 source_file = self.remote_file.get_child_for_display_name(filename)
150 target_file = Gio.File.new_for_path(local_path.name)150 target_file = Gio.File.new_for_path(local_path.name)
151 self.__copy_file(source_file, target_file)151 self.__copy_file(source_file, target_file)
152152
@@ -156,9 +156,7 @@
156 # We grab display name, rather than file name because some backends156 # We grab display name, rather than file name because some backends
157 # (e.g. google-drive:) use filesystem-specific IDs as file names and157 # (e.g. google-drive:) use filesystem-specific IDs as file names and
158 # only expose the "normal" name as display names. We need the display158 # only expose the "normal" name as display names. We need the display
159 # name, because we try to parse them. If the backend does this sort of159 # name, because we try to parse them.
160 # trickery, it will accept both versions of the filename, so we
161 # shouldn't get into any trouble doing this.
162 enum = self.remote_file.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,160 enum = self.remote_file.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
163 Gio.FileQueryInfoFlags.NONE,161 Gio.FileQueryInfoFlags.NONE,
164 None)162 None)
@@ -169,12 +167,12 @@
169 return files167 return files
170168
171 def _delete(self, filename):169 def _delete(self, filename):
172 target_file = self.remote_file.get_child(filename)170 target_file = self.remote_file.get_child_for_display_name(filename)
173 target_file.delete(None)171 target_file.delete(None)
174172
175 def _query(self, filename):173 def _query(self, filename):
176 from gi.repository import Gio # @UnresolvedImport174 from gi.repository import Gio # @UnresolvedImport
177 target_file = self.remote_file.get_child(filename)175 target_file = self.remote_file.get_child_for_display_name(filename)
178 info = target_file.query_info(Gio.FILE_ATTRIBUTE_STANDARD_SIZE,176 info = target_file.query_info(Gio.FILE_ATTRIBUTE_STANDARD_SIZE,
179 Gio.FileQueryInfoFlags.NONE, None)177 Gio.FileQueryInfoFlags.NONE, None)
180 return {'size': info.get_size()}178 return {'size': info.get_size()}

Subscribers

People subscribed via source and target branches