Refactor storage interface to return io.Reader and Writer instances

Doing so will enable encrypting/decrypting files in a 'pipeline' without
having to write the intermediate results to a file or store them in
their entirety in memory.

This commit also updates the existing storage classes (local and FTP) to
meet the new interface definition.
This commit is contained in:
2013-09-09 22:59:18 -04:00
parent 1254a7fb45
commit e2ae508382
5 changed files with 104 additions and 69 deletions

View File

@ -7,11 +7,14 @@ package main
import (
"code.google.com/p/goconf/conf"
"errors"
"io"
)
type Storage interface {
Put(filename string, hash string) error
Get(filename string, hash string) error
// Close() MUST be called on the returned io.WriteCloser
Put(hash string) (io.WriteCloser, error)
// Close() MUST be called on the returned io.ReadCloser
Get(hash string) (io.ReadCloser, error)
}
func GetStorage(config *conf.ConfigFile) (Storage, error) {