~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 20:42:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1989.
  • Revision ID: john@arbash-meinel.com-20060906204245-2c4b8481f344d692
Add ability to pass a directory mode to non_atomic_put

Show diffs side-by-side

added added

removed removed

Lines of Context:
426
426
            raise
427
427
 
428
428
    def _put_non_atomic_helper(self, relpath, writer, mode=None,
429
 
                               create_parent_dir=False):
 
429
                               create_parent_dir=False,
 
430
                               dir_mode=None):
430
431
        abspath = self._remote_path(relpath)
431
432
 
432
433
        # TODO: jam 20060816 paramiko doesn't publicly expose a way to
467
468
            parent_dir = os.path.dirname(abspath)
468
469
            try:
469
470
                self._sftp.mkdir(parent_dir)
 
471
                if dir_mode is not None:
 
472
                    self._sftp.chmod(path, mode=dir_mode)
470
473
            except (paramiko.SSHException, IOError), e:
471
474
                self._translate_io_exception(e, abspath, ': unable to open')
472
475
            _open_and_write_file()
473
476
 
474
477
    def put_file_non_atomic(self, relpath, f, mode=None,
475
 
                            create_parent_dir=False):
 
478
                            create_parent_dir=False,
 
479
                            dir_mode=None):
476
480
        """Copy the file-like object into the target location.
477
481
 
478
482
        This function is not strictly safe to use. It is only meant to
491
495
        def writer(fout):
492
496
            self._pump(f, fout)
493
497
        self._put_non_atomic_helper(relpath, writer, mode=mode,
494
 
                                    create_parent_dir=create_parent_dir)
 
498
                                    create_parent_dir=create_parent_dir,
 
499
                                    dir_mode=dir_mode)
495
500
 
496
501
    def put_bytes_non_atomic(self, relpath, bytes, mode=None,
497
 
                             create_parent_dir=False):
 
502
                             create_parent_dir=False,
 
503
                             dir_mode=None):
498
504
        def writer(fout):
499
505
            fout.write(bytes)
500
506
        self._put_non_atomic_helper(relpath, writer, mode=mode,
501
 
                                    create_parent_dir=create_parent_dir)
 
507
                                    create_parent_dir=create_parent_dir,
 
508
                                    dir_mode=dir_mode)
502
509
 
503
510
    def iter_files_recursive(self):
504
511
        """Walk the relative paths of all files in this transport."""