~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/smart.py

  • Committer: Robert Collins
  • Date: 2006-09-29 06:24:03 UTC
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20060929062403-7e8b779181d8766c
``Transport.get`` has had its interface made more clear for ease of use.
Retrieval of a directory must now fail with either 'PathError' at open
time, or raise 'ReadError' on a read. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
352
352
        return SmartServerResponse((r,))
353
353
 
354
354
    def do_get(self, relpath):
355
 
        backing_bytes = self._backing_transport.get_bytes(relpath)
 
355
        try:
 
356
            backing_bytes = self._backing_transport.get_bytes(relpath)
 
357
        except errors.ReadError:
 
358
            # cannot read the file
 
359
            return SmartServerResponse(('ReadError', ))
356
360
        return SmartServerResponse(('ok',), backing_bytes)
357
361
 
358
362
    def _deserialise_optional_mode(self, mode):
876
880
                raise UnicodeEncodeError(encoding, val, start, end, reason)
877
881
        elif what == "ReadOnlyError":
878
882
            raise errors.TransportNotPossible('readonly transport')
 
883
        elif what == "ReadError":
 
884
            if orig_path is not None:
 
885
                error_path = orig_path
 
886
            else:
 
887
                error_path = resp[1]
 
888
            raise errors.ReadError(error_path)
879
889
        else:
880
890
            raise errors.SmartProtocolError('unexpected smart server error: %r' % (resp,))
881
891