summaryrefslogtreecommitdiffstats
path: root/modules/storage/storage.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/storage/storage.go')
-rw-r--r--modules/storage/storage.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/modules/storage/storage.go b/modules/storage/storage.go
index ec3a1c14a1..65f8978e5a 100644
--- a/modules/storage/storage.go
+++ b/modules/storage/storage.go
@@ -65,7 +65,8 @@ type Object interface {
// ObjectStorage represents an object storage to handle a bucket and files
type ObjectStorage interface {
Open(path string) (Object, error)
- Save(path string, r io.Reader) (int64, error)
+ // Save store a object, if size is unknown set -1
+ Save(path string, r io.Reader, size int64) (int64, error)
Stat(path string) (os.FileInfo, error)
Delete(path string) error
URL(path, name string) (*url.URL, error)
@@ -80,7 +81,13 @@ func Copy(dstStorage ObjectStorage, dstPath string, srcStorage ObjectStorage, sr
}
defer f.Close()
- return dstStorage.Save(dstPath, f)
+ size := int64(-1)
+ fsinfo, err := f.Stat()
+ if err == nil {
+ size = fsinfo.Size()
+ }
+
+ return dstStorage.Save(dstPath, f, size)
}
// SaveFrom saves data to the ObjectStorage with path p from the callback
@@ -94,7 +101,7 @@ func SaveFrom(objStorage ObjectStorage, p string, callback func(w io.Writer) err
}
}()
- _, err := objStorage.Save(p, pr)
+ _, err := objStorage.Save(p, pr, -1)
return err
}