{"record":{"id":"e8305d1afe9ba920","repo":"Billionmail/BillionMail","slug":"open-maildirsize-failed-w","errorCode":null,"errorMessage":"open maildirsize failed: %w","messagePattern":"open maildirsize failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/internal/service/mail_boxes/update_used_space.go","lineNumber":194,"sourceCode":"\t\t} else {\n\t\t\tif err := tx.Commit(); err != nil {\n\n\t\t\t\tfailCount += len(batch)\n\t\t\t} else {\n\t\t\t\tsuccessCount += batchSuccess\n\t\t\t}\n\t\t}\n\t}\n\n\t//g.Log().Debug(ctx, \"Batch update completed\", \"success\", successCount, \"failed\", failCount)\n}\n\nfunc readMaildirsize(userDir string) (int64, error) {\n\tpath := filepath.Join(userDir, \"maildirsize\")\n\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"open maildirsize failed: %w\", err)\n\t}\n\tdefer f.Close()\n\n\tscanner := bufio.NewScanner(f)\n\tvar total int64\n\tvar lineNo int\n\n\tfor scanner.Scan() {\n\t\tlineNo++\n\t\tline := strings.TrimSpace(scanner.Text())\n\n\t\tif line == \"\" || strings.HasPrefix(line, \"#\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tparts := strings.Fields(line)\n\t\tif len(parts) == 0 {\n\t\t\tcontinue","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/mail_boxes/update_used_space.go#L176-L212","documentation":"readMaildirsize opens the 'maildirsize' file inside a user's maildir to compute used quota space; this error wraps any os.Open failure (missing file or permission denied) when updating a mailbox's used space. It means the used-space calculation could not read its data source for that user.","triggerScenarios":"Calling the used-space update path (anonymous caller) for a user directory that has no maildirsize file, or one the process cannot read (wrong ownership/permissions).","commonSituations":"Mailbox created but never received mail (maildirsize not yet created by Dovecot); maildir mounted/copied with wrong ownership; user directory path computed incorrectly.","solutions":["Verify the user's maildir exists and contains a maildirsize file; send a test mail or let Dovecot initialize quotas","Check file ownership/permissions so the BillionMail process can read the maildir","Confirm the userDir path passed to readMaildirsize is correct for that mailbox","Treat missing maildirsize as zero usage upstream if that is acceptable for your setup"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if _, err := os.Stat(filepath.Join(userDir, \"maildirsize\")); os.IsNotExist(err) {\n    // maildir not initialized; treat used space as 0 or skip\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"open maildirsize failed\") {\n    if os.IsNotExist(errors.Unwrap(err)) {\n        // default used space to 0 and continue\n    }\n}","preventionTips":["Ensure Dovecot initializes maildirsize for new mailboxes (send a welcome mail)","Keep maildir ownership consistent with the app user","Verify userDir path construction before quota updates"],"tags":["go","filesystem","quota","maildir"],"backgroundTag":"file-not-found","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}