~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-06 21:51:39 UTC
  • mfrom: (1988.1.1 sftp_mode_bits)
  • mto: This revision was merged to the branch mainline in revision 1989.
  • Revision ID: john@arbash-meinel.com-20060906215139-48d4e17bcf86a97c
Fix the sftp mkdir mode code

Show diffs side-by-side

added added

removed removed

Lines of Context:
466
466
            # Try to create the parent directory, and then go back to
467
467
            # writing the file
468
468
            parent_dir = os.path.dirname(abspath)
469
 
            try:
470
 
                self._sftp.mkdir(parent_dir)
471
 
                if dir_mode is not None:
472
 
                    self._sftp.chmod(path, mode=dir_mode)
473
 
            except (paramiko.SSHException, IOError), e:
474
 
                self._translate_io_exception(e, abspath, ': unable to open')
 
469
            self._mkdir(parent_dir, dir_mode)
475
470
            _open_and_write_file()
476
471
 
477
472
    def put_file_non_atomic(self, relpath, f, mode=None,
519
514
            else:
520
515
                yield relpath
521
516
 
 
517
    def _mkdir(self, abspath, mode=None):
 
518
        if mode is None:
 
519
            local_mode = 0777
 
520
        else:
 
521
            local_mode = mode
 
522
        try:
 
523
            self._sftp.mkdir(abspath, local_mode)
 
524
            if mode is not None:
 
525
                self._sftp.chmod(abspath, mode=mode)
 
526
        except (paramiko.SSHException, IOError), e:
 
527
            self._translate_io_exception(e, abspath, ': unable to mkdir',
 
528
                failure_exc=FileExists)
 
529
 
522
530
    def mkdir(self, relpath, mode=None):
523
531
        """Create a directory at the given path."""
524
 
        path = self._remote_path(relpath)
525
 
        try:
526
 
            self._sftp.mkdir(path)
527
 
            if mode is not None:
528
 
                self._sftp.chmod(path, mode=mode)
529
 
        except (paramiko.SSHException, IOError), e:
530
 
            self._translate_io_exception(e, path, ': unable to mkdir',
531
 
                failure_exc=FileExists)
 
532
        self._mkdir(self._remote_path(relpath), mode=mode)
532
533
 
533
534
    def _translate_io_exception(self, e, path, more_info='', 
534
535
                                failure_exc=PathError):
752
753
            self._translate_io_exception(e, abspath, ': unable to open',
753
754
                failure_exc=FileExists)
754
755
 
 
756
    def _can_roundtrip_unix_modebits(self):
 
757
        if sys.platform == 'win32':
 
758
            # anyone else?
 
759
            return False
 
760
        else:
 
761
            return True
755
762
 
756
763
# ------------- server test implementation --------------
757
764
import threading