mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-30 12:03:34 -06:00
*fiddles*
This commit is contained in:
parent
11b18f986c
commit
48ab34f71a
12 changed files with 221 additions and 74 deletions
31
internal/storage/inmem.go
Normal file
31
internal/storage/inmem.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
)
|
||||
|
||||
func NewInMem(c *config.Config, log *logrus.Logger) (Storage, error) {
|
||||
return &inMemStorage{
|
||||
stored: make(map[string][]byte),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type inMemStorage struct {
|
||||
stored map[string][]byte
|
||||
}
|
||||
|
||||
func (s *inMemStorage) StoreFileAt(path string, data []byte) error {
|
||||
s.stored[path] = data
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *inMemStorage) RetrieveFileFrom(path string) ([]byte, error) {
|
||||
d, ok := s.stored[path]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("no data found at path %s", path)
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
21
internal/storage/local.go
Normal file
21
internal/storage/local.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
)
|
||||
|
||||
func NewLocal(c *config.Config, log *logrus.Logger) (Storage, error) {
|
||||
return &localStorage{}, nil
|
||||
}
|
||||
|
||||
type localStorage struct {
|
||||
}
|
||||
|
||||
func (s *localStorage) StoreFileAt(path string, data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *localStorage) RetrieveFileFrom(path string) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
@ -18,16 +18,7 @@
|
|||
|
||||
package storage
|
||||
|
||||
import "time"
|
||||
|
||||
type Storage interface {
|
||||
StoreFileAt(path string, data []byte) error
|
||||
RetrieveFileFrom(path string) ([]byte, error)
|
||||
}
|
||||
|
||||
type FileInfo struct {
|
||||
Data []byte
|
||||
StorePath string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue