1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

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.
This commit is contained in:
James Hillyerd
2012-10-23 13:51:33 -07:00
parent 30d7cbc2a4
commit 9789eab6cf

View File

@@ -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