1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-21 19:47:03 +00:00

Message size calculation changes

Message sizes are now calculated as the message is written out to disk,
and saved into the index.gob file
This commit is contained in:
James Hillyerd
2013-10-13 21:03:51 -07:00
parent b7e1dbb418
commit 46d4f7be1d
2 changed files with 38 additions and 11 deletions

View File

@@ -275,6 +275,7 @@ type FileMessage struct {
Fdate time.Time
Ffrom string
Fsubject string
Fsize int64
// These are for creating new messages only
writable bool
writerFile *os.File
@@ -310,11 +311,7 @@ func (m *FileMessage) String() string {
}
func (m *FileMessage) Size() int64 {
fi, err := os.Stat(m.rawPath())
if err != nil {
return 0
}
return fi.Size()
return m.Fsize
}
func (m *FileMessage) rawPath() string {
@@ -399,6 +396,7 @@ func (m *FileMessage) Append(data []byte) error {
m.writer = bufio.NewWriter(file)
}
_, err := m.writer.Write(data)
m.Fsize += int64(len(data))
return err
}