1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-06-12 23:57:40 +02:00

Fix: Prevent runtime error when calculating total messages size of empty table ()

This commit is contained in:
Ralph Slooten 2024-03-10 07:48:44 +13:00
parent bdea197a0f
commit d1d0ce4737

@ -51,7 +51,7 @@ func getDeletedSize() int64 {
// The total raw non-compressed messages size in bytes of all messages in the database // The total raw non-compressed messages size in bytes of all messages in the database
func totalMessagesSize() int64 { func totalMessagesSize() int64 {
var result int64 var result sql.NullInt64
err := sqlf.From("mailbox"). err := sqlf.From("mailbox").
Select("SUM(Size)").To(&result). Select("SUM(Size)").To(&result).
QueryAndClose(nil, db, func(row *sql.Rows) {}) QueryAndClose(nil, db, func(row *sql.Rows) {})
@ -60,7 +60,7 @@ func totalMessagesSize() int64 {
return 0 return 0
} }
return result return result.Int64
} }
// AddDeletedSize will add the value to the DeletedSize setting // AddDeletedSize will add the value to the DeletedSize setting