Skip to content

Commit

Permalink
fix mailhog/MailHog-UI#10 - delete for in-memory storage
Browse files Browse the repository at this point in the history
FIXME fix is nasty, especially with lots of messages, or deleting
using concurrent API requests
  • Loading branch information
ian-kent committed Oct 6, 2015
1 parent 153c814 commit 33a9b88
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ func (memory *InMemory) List(start int, limit int) (*data.Messages, error) {
func (memory *InMemory) DeleteOne(id string) error {
index := memory.MessageIDIndex[id]
delete(memory.MessageIDIndex, id)
for k, v := range memory.MessageIDIndex {
if v > index {
memory.MessageIDIndex[k] = v - 1
}
}
memory.Messages = append(memory.Messages[:index], memory.Messages[index+1:]...)
return nil
}
Expand Down

0 comments on commit 33a9b88

Please sign in to comment.