From 2e3ecdca37622933742e9ac405c96d275ef4ed69 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Tue, 2 Dec 2014 21:47:28 -0800 Subject: [PATCH] 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. --- storagedriver/storagedriver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storagedriver/storagedriver.go b/storagedriver/storagedriver.go index 754c8bb6b..339b465a7 100644 --- a/storagedriver/storagedriver.go +++ b/storagedriver/storagedriver.go @@ -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.