mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +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:
@@ -60,7 +60,8 @@ func NewDataStore() *DataStore {
|
|||||||
func (ds *DataStore) MailboxFor(emailAddress string) (*Mailbox, error) {
|
func (ds *DataStore) MailboxFor(emailAddress string) (*Mailbox, error) {
|
||||||
name := ParseMailboxName(emailAddress)
|
name := ParseMailboxName(emailAddress)
|
||||||
dir := HashMailboxName(name)
|
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 {
|
if err := os.MkdirAll(path, 0770); err != nil {
|
||||||
log.Error("Failed to create directory %v, %v", path, err)
|
log.Error("Failed to create directory %v, %v", path, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user