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