~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Martin Pool
  • Date: 2009-03-12 05:32:56 UTC
  • mfrom: (4124 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4140.
  • Revision ID: mbp@sourcefrog.net-20090312053256-071khr6k4wwuuyja
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
406
406
        """
407
407
        try:
408
408
            self._get_sftp().stat(self._remote_path(relpath))
 
409
            # stat result is about 20 bytes, let's say
 
410
            self._report_activity(20, 'read')
409
411
            return True
410
412
        except IOError:
411
413
            return False
416
418
        :param relpath: The relative path to the file
417
419
        """
418
420
        try:
 
421
            # FIXME: by returning the file directly, we don't pass this
 
422
            # through to report_activity.  We could try wrapping the object
 
423
            # before it's returned.  For readv and get_bytes it's handled in
 
424
            # the higher-level function.
 
425
            # -- mbp 20090126
419
426
            path = self._remote_path(relpath)
420
427
            f = self._get_sftp().file(path, mode='rb')
421
428
            if self._do_prefetch and (getattr(f, 'prefetch', None) is not None):
612
619
 
613
620
    def iter_files_recursive(self):
614
621
        """Walk the relative paths of all files in this transport."""
 
622
        # progress is handled by list_dir
615
623
        queue = list(self.list_dir('.'))
616
624
        while queue:
617
625
            relpath = queue.pop(0)
628
636
        else:
629
637
            local_mode = mode
630
638
        try:
 
639
            self._report_activity(len(abspath), 'write')
631
640
            self._get_sftp().mkdir(abspath, local_mode)
 
641
            self._report_activity(1, 'read')
632
642
            if mode is not None:
633
643
                # chmod a dir through sftp will erase any sgid bit set
634
644
                # on the server side.  So, if the bit mode are already
779
789
        path = self._remote_path(relpath)
780
790
        try:
781
791
            entries = self._get_sftp().listdir(path)
 
792
            self._report_activity(sum(map(len, entries)), 'read')
782
793
        except (IOError, paramiko.SSHException), e:
783
794
            self._translate_io_exception(e, path, ': failed to list_dir')
784
795
        return [urlutils.escape(entry) for entry in entries]