From 318d1bb6f929bdbe2930f04f638f807d869a71b8 Mon Sep 17 00:00:00 2001 From: Cnly Date: Sat, 19 Jan 2019 21:51:34 +0800 Subject: [PATCH] fs: clarify behaviour of Put() and Upload() for unknown-sized objects --- fs/fs.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/fs.go b/fs/fs.go index 6a3b3a282..f8ded9ed6 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -227,6 +227,10 @@ type Fs interface { // Put in to the remote path with the modTime given of the given size // + // When called from outside a Fs by rclone, src.Size() will always be >= 0. + // But for unknown-sized objects (indicated by src.Size() == -1), Put should either + // return an error or upload it properly (rather than e.g. calling panic). + // // May create the object even if it returns an error - if so // will return the object and the error, otherwise will return // nil and the error @@ -275,6 +279,10 @@ type Object interface { Open(options ...OpenOption) (io.ReadCloser, error) // Update in to the object with the modTime given of the given size + // + // When called from outside a Fs by rclone, src.Size() will always be >= 0. + // But for unknown-sized objects (indicated by src.Size() == -1), Upload should either + // return an error or update the object properly (rather than e.g. calling panic). Update(in io.Reader, src ObjectInfo, options ...OpenOption) error // Removes this object