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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user