Fix stream_write to properly raise an exception on failure, instead of just silently failing

This was causing problems for customers using georeplication over unstable storage engines

Also adds tests for stream_write and copy,  to ensure we detect failure
This commit is contained in:
Joseph Schorr 2018-10-31 12:46:49 -04:00
parent a048ff3633
commit 3a0adfcb11
3 changed files with 59 additions and 18 deletions

View file

@ -84,7 +84,7 @@ class BaseStorage(StoragePaths):
def stream_write_to_fp(self, in_fp, out_fp, num_bytes=READ_UNTIL_END):
""" Copy the specified number of bytes from the input file stream to the output stream. If
num_bytes < 0 copy until the stream ends.
num_bytes < 0 copy until the stream ends. Returns the number of bytes copied.
"""
bytes_copied = 0
while bytes_copied < num_bytes or num_bytes == READ_UNTIL_END: