50 with lfutil.httpsendfile(self.ui, filename) as fd: |
50 with lfutil.httpsendfile(self.ui, filename) as fd: |
51 return self._put(hash, fd) |
51 return self._put(hash, fd) |
52 except IOError as e: |
52 except IOError as e: |
53 raise error.Abort( |
53 raise error.Abort( |
54 _('remotestore: could not open file %s: %s') |
54 _('remotestore: could not open file %s: %s') |
55 % (filename, str(e))) |
55 % (filename, util.forcebytestr(e))) |
56 |
56 |
57 def _getfile(self, tmpfile, filename, hash): |
57 def _getfile(self, tmpfile, filename, hash): |
58 try: |
58 try: |
59 chunks = self._get(hash) |
59 chunks = self._get(hash) |
60 except urlerr.httperror as e: |
60 except urlerr.httperror as e: |
61 # 401s get converted to error.Aborts; everything else is fine being |
61 # 401s get converted to error.Aborts; everything else is fine being |
62 # turned into a StoreError |
62 # turned into a StoreError |
63 raise basestore.StoreError(filename, hash, self.url, str(e)) |
63 raise basestore.StoreError(filename, hash, self.url, |
|
64 util.forcebytestr(e)) |
64 except urlerr.urlerror as e: |
65 except urlerr.urlerror as e: |
65 # This usually indicates a connection problem, so don't |
66 # This usually indicates a connection problem, so don't |
66 # keep trying with the other files... they will probably |
67 # keep trying with the other files... they will probably |
67 # all fail too. |
68 # all fail too. |
68 raise error.Abort('%s: %s' % |
69 raise error.Abort('%s: %s' % |
69 (util.hidepassword(self.url), e.reason)) |
70 (util.hidepassword(self.url), e.reason)) |
70 except IOError as e: |
71 except IOError as e: |
71 raise basestore.StoreError(filename, hash, self.url, str(e)) |
72 raise basestore.StoreError(filename, hash, self.url, |
|
73 util.forcebytestr(e)) |
72 |
74 |
73 return lfutil.copyandhash(chunks, tmpfile) |
75 return lfutil.copyandhash(chunks, tmpfile) |
74 |
76 |
75 def _hashesavailablelocally(self, hashes): |
77 def _hashesavailablelocally(self, hashes): |
76 existslocallymap = self._lstore.exists(hashes) |
78 existslocallymap = self._lstore.exists(hashes) |