1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-23 12:37:07 +00:00

Refactor datastore into it's own package for #67

This commit is contained in:
James Hillyerd
2017-12-26 14:54:49 -08:00
parent cc47895d71
commit 3a4fd3f093
17 changed files with 93 additions and 84 deletions

View File

@@ -11,6 +11,7 @@ import (
"time"
"github.com/jhillyerd/enmime"
"github.com/jhillyerd/inbucket/datastore"
"github.com/jhillyerd/inbucket/log"
)
@@ -33,7 +34,7 @@ type FileMessage struct {
// NewMessage creates a new FileMessage object and sets the Date and Id fields.
// It will also delete messages over messageCap if configured.
func (mb *FileMailbox) NewMessage() (Message, error) {
func (mb *FileMailbox) NewMessage() (datastore.Message, error) {
// Load index
if !mb.indexLoaded {
if err := mb.readIndex(); err != nil {
@@ -165,7 +166,7 @@ func (m *FileMessage) ReadRaw() (raw *string, err error) {
func (m *FileMessage) Append(data []byte) error {
// Prevent Appending to a pre-existing Message
if !m.writable {
return ErrNotWritable
return datastore.ErrNotWritable
}
// Open file for writing if we haven't yet
if m.writer == nil {