Merge lp:~mterry/duplicity/gio_child_for_display_name into lp:~duplicity-team/duplicity/0.8-series

Proposed by Michael Terry
Status: Merged
Merged at revision: 1256
Proposed branch: lp:~mterry/duplicity/gio_child_for_display_name
Merge into: lp:~duplicity-team/duplicity/0.8-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
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+329048@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
1=== modified file 'duplicity/backends/giobackend.py'
2--- duplicity/backends/giobackend.py 2017-08-05 21:39:11 +0000
3+++ duplicity/backends/giobackend.py 2017-08-15 15:49:51 +0000
4@@ -141,12 +141,12 @@
5 def _put(self, source_path, remote_filename):
6 from gi.repository import Gio # @UnresolvedImport
7 source_file = Gio.File.new_for_path(source_path.name)
8- target_file = self.remote_file.get_child(remote_filename)
9+ target_file = self.remote_file.get_child_for_display_name(remote_filename)
10 self.__copy_file(source_file, target_file)
11
12 def _get(self, filename, local_path):
13 from gi.repository import Gio # @UnresolvedImport
14- source_file = self.remote_file.get_child(filename)
15+ source_file = self.remote_file.get_child_for_display_name(filename)
16 target_file = Gio.File.new_for_path(local_path.name)
17 self.__copy_file(source_file, target_file)
18
19@@ -156,9 +156,7 @@
20 # We grab display name, rather than file name because some backends
21 # (e.g. google-drive:) use filesystem-specific IDs as file names and
22 # only expose the "normal" name as display names. We need the display
23- # name, because we try to parse them. If the backend does this sort of
24- # trickery, it will accept both versions of the filename, so we
25- # shouldn't get into any trouble doing this.
26+ # name, because we try to parse them.
27 enum = self.remote_file.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
28 Gio.FileQueryInfoFlags.NONE,
29 None)
30@@ -169,12 +167,12 @@
31 return files
32
33 def _delete(self, filename):
34- target_file = self.remote_file.get_child(filename)
35+ target_file = self.remote_file.get_child_for_display_name(filename)
36 target_file.delete(None)
37
38 def _query(self, filename):
39 from gi.repository import Gio # @UnresolvedImport
40- target_file = self.remote_file.get_child(filename)
41+ target_file = self.remote_file.get_child_for_display_name(filename)
42 info = target_file.query_info(Gio.FILE_ATTRIBUTE_STANDARD_SIZE,
43 Gio.FileQueryInfoFlags.NONE, None)
44 return {'size': info.get_size()}

Subscribers

People subscribed via source and target branches