Remove size argument and using io.Reader for StorageDriver.WriteStream

We are change the the rpc call for WriteStream to not require the size
argument, opting to drive the process with io.Reader. The main issue was that
io.Reader may return io.EOF before reaching size, making the error handling
around this condition for callers more complex. To complement this, WriteStream
now returns the number of successfully written bytes.

The method no longer requires an io.ReadCloser, opting to require just an
io.Reader. This keeps the reader under the control of the caller, which
provides more flexibility.

This also begins to address some of the problems described in #791.
This commit is contained in:
Stephen J Day 2014-12-02 21:47:28 -08:00
parent ac660e72bf
commit 2e3ecdca37

View File

@ -52,7 +52,7 @@ type StorageDriver interface {
// "size" bytes.
// May be used to resume writing a stream by providing a nonzero offset.
// The offset must be no larger than the CurrentSize for this path.
WriteStream(path string, offset, size int64, readCloser io.ReadCloser) error
WriteStream(path string, offset int64, reader io.Reader) (nn int64, err error)
// Stat retrieves the FileInfo for the given path, including the current
// size in bytes and the creation time.