Skip to content

Commit

Permalink
simplified copy_file_data
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Nov 22, 2016
1 parent 6dab4a7 commit 667edbd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
import io


DEFAULT_CHUNK_SIZE = io.DEFAULT_BUFFER_SIZE * 10
DEFAULT_CHUNK_SIZE = io.DEFAULT_BUFFER_SIZE * 16
9 changes: 1 addition & 8 deletions fs/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,13 @@ def copy_file_data(src_file, dst_file, chunk_size=None):
:param file-like dst_file: File open for writing.
:param int chunk_size: Number of bytes to copy at a time (or
``None`` to use sensible default).
:returns: Number of bytes copied.
:rtype: int
"""
chunk_size = chunk_size or constants.DEFAULT_CHUNK_SIZE
count = 0
read = src_file.read
write = dst_file.write
chunk = read(chunk_size)
while chunk:
for chunk in iter(lambda: read(chunk_size), b''):
write(chunk)
count += len(chunk)
chunk = read(chunk_size)
return count


def get_intermediate_dirs(fs, dir_path):
Expand Down

0 comments on commit 667edbd

Please sign in to comment.