~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/smart.py

  • Committer: Andrew Bennetts
  • Date: 2006-10-12 08:58:01 UTC
  • mto: (2018.4.8 FastCGI)
  • mto: This revision was merged to the branch mainline in revision 2144.
  • Revision ID: andrew.bennetts@canonical.com-20061012085801-36b60463388ea0e7
Fix dispatching of smart server requests involving unicode paths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
560
560
                return
561
561
            bytes = self._in.read(bytes_to_read)
562
562
            if bytes == '':
 
563
 
563
564
                # Connection has been closed.
564
565
                self.finished = True
565
566
                self._out.flush()
635
636
        return SmartServerResponse(('ok', '1'))
636
637
 
637
638
    def do_has(self, relpath):
 
639
        relpath = relpath.encode('utf-8')
638
640
        r = self._backing_transport.has(relpath) and 'yes' or 'no'
639
641
        return SmartServerResponse((r,))
640
642
 
641
643
    def do_get(self, relpath):
 
644
        relpath = relpath.encode('utf-8')
642
645
        backing_bytes = self._backing_transport.get_bytes(relpath)
643
646
        return SmartServerResponse(('ok',), backing_bytes)
644
647
 
651
654
 
652
655
    def do_append(self, relpath, mode):
653
656
        self._converted_command = True
654
 
        self._relpath = relpath
 
657
        self._relpath = relpath.encode('utf-8')
655
658
        self._mode = self._deserialise_optional_mode(mode)
656
659
        self._end_of_body_handler = self._handle_do_append_end
657
660
    
661
664
        self.response = SmartServerResponse(('appended', '%d' % old_length))
662
665
 
663
666
    def do_delete(self, relpath):
 
667
        relpath = relpath.encode('utf-8')
664
668
        self._backing_transport.delete(relpath)
665
669
 
666
 
    def do_iter_files_recursive(self, abspath):
667
 
        # XXX: the path handling needs some thought.
668
 
        #relpath = self._backing_transport.relpath(abspath)
669
 
        transport = self._backing_transport.clone(abspath)
 
670
    def do_iter_files_recursive(self, relpath):
 
671
        relpath = relpath.encode('utf-8')
 
672
        transport = self._backing_transport.clone(relpath)
670
673
        filenames = transport.iter_files_recursive()
671
674
        return SmartServerResponse(('names',) + tuple(filenames))
672
675
 
673
676
    def do_list_dir(self, relpath):
 
677
        relpath = relpath.encode('utf-8')
674
678
        filenames = self._backing_transport.list_dir(relpath)
675
679
        return SmartServerResponse(('names',) + tuple(filenames))
676
680
 
677
681
    def do_mkdir(self, relpath, mode):
 
682
        relpath = relpath.encode('utf-8')
678
683
        self._backing_transport.mkdir(relpath,
679
684
                                      self._deserialise_optional_mode(mode))
680
685
 
681
686
    def do_move(self, rel_from, rel_to):
 
687
        rel_from = rel_from.encode('utf-8')
 
688
        rel_to = rel_to.encode('utf-8')
682
689
        self._backing_transport.move(rel_from, rel_to)
683
690
 
684
691
    def do_put(self, relpath, mode):
685
692
        self._converted_command = True
686
 
        self._relpath = relpath
 
693
        self._relpath = relpath.encode('utf-8')
687
694
        self._mode = self._deserialise_optional_mode(mode)
688
695
        self._end_of_body_handler = self._handle_do_put
689
696
 
705
712
    def do_put_non_atomic(self, relpath, mode, create_parent, dir_mode):
706
713
        self._converted_command = True
707
714
        self._end_of_body_handler = self._handle_put_non_atomic
708
 
        self._relpath = relpath
 
715
        self._relpath = relpath.encode('utf-8')
709
716
        self._dir_mode = self._deserialise_optional_mode(dir_mode)
710
717
        self._mode = self._deserialise_optional_mode(mode)
711
718
        # a boolean would be nicer XXX
722
729
    def do_readv(self, relpath):
723
730
        self._converted_command = True
724
731
        self._end_of_body_handler = self._handle_readv_offsets
725
 
        self._relpath = relpath
 
732
        self._relpath = relpath.encode('utf-8')
726
733
 
727
734
    def end_of_body(self):
728
735
        """No more body data will be received."""
738
745
        self.response = SmartServerResponse(('readv',), backing_bytes)
739
746
        
740
747
    def do_rename(self, rel_from, rel_to):
 
748
        rel_from = rel_from.encode('utf-8')
 
749
        rel_to = rel_to.encode('utf-8')
741
750
        self._backing_transport.rename(rel_from, rel_to)
742
751
 
743
752
    def do_rmdir(self, relpath):
 
753
        relpath = relpath.encode('utf-8')
744
754
        self._backing_transport.rmdir(relpath)
745
755
 
746
756
    def do_stat(self, relpath):
 
757
        relpath = relpath.encode('utf-8')
747
758
        stat = self._backing_transport.stat(relpath)
748
759
        return SmartServerResponse(('stat', str(stat.st_size), oct(stat.st_mode)))
749
760