~thomas-ross/duplicity/b2-hide-files

« back to all changes in this revision

Viewing changes to duplicity/backends/pcabackend.py

  • Committer: Kenneth Loafman
  • Date: 2020-03-14 15:15:57 UTC
  • Revision ID: kenneth@loafman.com-20200314151557-4l2zclw9y7czbhx9
* Fixed bug #1867435 - TypeError: must be str,
  not bytes using PCA backend

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
            log.FatalError(u"Container '%s' exists but its storage policy is '%s' not '%s'."
145
145
                           % (self.container, container_metadata[policy_header.lower()], policy))
146
146
 
147
 
    def _error_code(self, operation, e):
 
147
    def _error_code(self, operation, e):  # pylint: disable: unused-argument
148
148
        if isinstance(e, self.resp_exc):
149
149
            if e.http_status == 404:
150
150
                return log.ErrorCode.backend_not_found
151
151
 
152
152
    def _put(self, source_path, remote_filename):
153
 
        self.conn.put_object(self.container, self.prefix + remote_filename,
 
153
        self.conn.put_object(self.container, self.prefix + util.fsdecode(remote_filename),
154
154
                             open(source_path.name))
155
155
 
156
156
    def _get(self, remote_filename, local_path):
157
 
        body = self.preprocess_download(remote_filename, 60)
 
157
        body = self.preprocess_download(util.fsdecode(remote_filename), 60)
158
158
        if body:
159
159
            with open(local_path.name, u'wb') as f:
160
160
                for chunk in body:
163
163
    def _list(self):
164
164
        headers, objs = self.conn.get_container(self.container, full_listing=True, path=self.prefix)
165
165
        # removes prefix from return values. should check for the prefix ?
166
 
        return [o[u'name'][len(self.prefix):] for o in objs]
 
166
        return [util.fsencode(o[u'name'][len(self.prefix):]) for o in objs]
167
167
 
168
168
    def _delete(self, filename):
169
 
        self.conn.delete_object(self.container, self.prefix + filename)
 
169
        self.conn.delete_object(self.container, self.prefix + util.fsdecode(filename))
170
170
 
171
171
    def _query(self, filename):
172
 
        sobject = self.conn.head_object(self.container, self.prefix + filename)
 
172
        sobject = self.conn.head_object(self.container, self.prefix + util.fsdecode(filename))
173
173
        return {u'size': int(sobject[u'content-length'])}
174
174
 
175
175
    def preprocess_download(self, remote_filename, retry_period, wait=True):