diff --git a/store/interfaces.go b/store/interfaces.go deleted file mode 100644 index 8a8f145d1..000000000 --- a/store/interfaces.go +++ /dev/null @@ -1,23 +0,0 @@ -package store - -import "io" - -type ( - store struct { - namespace string - - originalFn func(id uint64, ext string) string - previewFn func(id uint64, ext string) string - } - - Store interface { - Namespace() string - - Original(id uint64, ext string) string - Preview(id uint64, ext string) string - - Save(filename string, contents io.Reader) error - Remove(filename string) error - Open(filename string) (io.Reader, error) - } -) diff --git a/store/store.go b/store/store.go index acf68804c..84283da36 100644 --- a/store/store.go +++ b/store/store.go @@ -5,8 +5,28 @@ import ( "io" "path" - "github.com/spf13/afero" "github.com/pkg/errors" + "github.com/spf13/afero" +) + +type ( + store struct { + namespace string + + originalFn func(id uint64, ext string) string + previewFn func(id uint64, ext string) string + } + + Store interface { + Namespace() string + + Original(id uint64, ext string) string + Preview(id uint64, ext string) string + + Save(filename string, contents io.Reader) error + Remove(filename string) error + Open(filename string) (afero.File, error) + } ) func New(namespace string) (Store, error) { @@ -26,7 +46,7 @@ func (s *store) Namespace() string { } func (s *store) check(filename string) error { - if filename[:len(s.namespace)+1] != s.namespace + "/" { + if filename[:len(s.namespace)+1] != s.namespace+"/" { return errors.Errorf("Invalid namespace when trying to store file: %s (for %s)", filename, s.namespace) } return nil @@ -64,7 +84,7 @@ func (s *store) Remove(filename string) error { return fs.Remove(filename) } -func (s *store) Open(filename string) (io.Reader, error) { +func (s *store) Open(filename string) (afero.File, error) { // check filename for validity if err := s.check(filename); err != nil { return nil, err diff --git a/store/store_test.go b/store/store_test.go index 384bcee2e..338d2e393 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -1,8 +1,8 @@ package store_test import ( - "io" "bytes" + "io" "testing" "github.com/crusttech/crust/store"