~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Vincent Ladeuil
  • Date: 2017-01-30 14:30:10 UTC
  • mfrom: (6615.3.7 merges)
  • mto: This revision was merged to the branch mainline in revision 6621.
  • Revision ID: v.ladeuil+lp@free.fr-20170130143010-p31t1ranfeqbaeki
Merge  2.7 into trunk including fix for bug #1657238

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011, 2016, 2017 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
410
410
        try:
411
411
            path = self._remote_path(relpath)
412
412
            f = self._get_sftp().file(path, mode='rb')
 
413
            size = f.stat().st_size
413
414
            if self._do_prefetch and (getattr(f, 'prefetch', None) is not None):
414
 
                f.prefetch()
 
415
                f.prefetch(size)
415
416
            return f
416
417
        except (IOError, paramiko.SSHException), e:
417
418
            self._translate_io_exception(e, path, ': error retrieving',
593
594
                                    create_parent_dir=create_parent_dir,
594
595
                                    dir_mode=dir_mode)
595
596
 
596
 
    def put_bytes_non_atomic(self, relpath, bytes, mode=None,
 
597
    def put_bytes_non_atomic(self, relpath, raw_bytes, mode=None,
597
598
                             create_parent_dir=False,
598
599
                             dir_mode=None):
 
600
        if not isinstance(raw_bytes, str):
 
601
            raise TypeError(
 
602
                'raw_bytes must be a plain string, not %s' % type(raw_bytes))
 
603
 
599
604
        def writer(fout):
600
 
            fout.write(bytes)
 
605
            fout.write(raw_bytes)
601
606
        self._put_non_atomic_helper(relpath, writer, mode=mode,
602
607
                                    create_parent_dir=create_parent_dir,
603
608
                                    dir_mode=dir_mode)