From 9789eab6cf4acfe877379f63df34461ca03208c7 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Tue, 23 Oct 2012 13:51:33 -0700 Subject: [PATCH] Limit datastore/mail to 65k dirs Added a new layer where we take the first 4 chars of the mailbox hash and use it to create directories. Should prevent us from having a million directories under "mail" directly. --- smtpd/datastore.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smtpd/datastore.go b/smtpd/datastore.go index e623174..8d2ad62 100644 --- a/smtpd/datastore.go +++ b/smtpd/datastore.go @@ -60,7 +60,8 @@ func NewDataStore() *DataStore { func (ds *DataStore) MailboxFor(emailAddress string) (*Mailbox, error) { name := ParseMailboxName(emailAddress) dir := HashMailboxName(name) - path := filepath.Join(ds.mailPath, dir) + section := dir[0:4] + path := filepath.Join(ds.mailPath, section, dir) if err := os.MkdirAll(path, 0770); err != nil { log.Error("Failed to create directory %v, %v", path, err) return nil, err