mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 22:54:38 +03:00
rename variables, struct fields and functions to include an "x" when they can panic for handling errors
and document the convention in develop.txt. spurred by running errcheck again (it has been a while). it still has too many false to enable by default.
This commit is contained in:
@ -231,7 +231,7 @@ func (a *Account) ResetThreading(ctx context.Context, log mlog.Log, batchSize in
|
||||
// Does not set Seen flag for muted threads.
|
||||
//
|
||||
// Progress is written to progressWriter, every 100k messages.
|
||||
func (a *Account) AssignThreads(ctx context.Context, log mlog.Log, txOpt *bstore.Tx, startMessageID int64, batchSize int, progressWriter io.Writer) error {
|
||||
func (a *Account) AssignThreads(ctx context.Context, log mlog.Log, txOpt *bstore.Tx, startMessageID int64, batchSize int, xprogressWriter io.Writer) error {
|
||||
// We use a more basic version of the thread-matching algorithm describe in:
|
||||
// ../rfc/5256:443
|
||||
// The algorithm assumes you'll select messages, then group into threads. We normally do
|
||||
@ -240,6 +240,9 @@ func (a *Account) AssignThreads(ctx context.Context, log mlog.Log, txOpt *bstore
|
||||
// soon as we process them. We can handle large number of messages, but not very
|
||||
// quickly because we make lots of database queries.
|
||||
|
||||
// xprogressWriter can call panic on write errors, when assigning threads through a
|
||||
// ctl command.
|
||||
|
||||
type childMsg struct {
|
||||
ID int64 // This message will be fetched and updated with the threading fields once the parent is resolved.
|
||||
MessageID string // Of child message. Once child is resolved, its own children can be resolved too.
|
||||
@ -533,18 +536,18 @@ func (a *Account) AssignThreads(ctx context.Context, log mlog.Log, txOpt *bstore
|
||||
nassigned += n
|
||||
if nassigned%100000 == 0 {
|
||||
log.Debug("assigning threads, progress", slog.Int("count", nassigned), slog.Int("unresolved", len(pending)))
|
||||
if _, err := fmt.Fprintf(progressWriter, "assigning threads, progress: %d messages\n", nassigned); err != nil {
|
||||
if _, err := fmt.Fprintf(xprogressWriter, "assigning threads, progress: %d messages\n", nassigned); err != nil {
|
||||
return fmt.Errorf("writing progress: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if _, err := fmt.Fprintf(progressWriter, "assigning threads, done: %d messages\n", nassigned); err != nil {
|
||||
if _, err := fmt.Fprintf(xprogressWriter, "assigning threads, done: %d messages\n", nassigned); err != nil {
|
||||
return fmt.Errorf("writing progress: %v", err)
|
||||
}
|
||||
|
||||
log.Debug("assigning threads, mostly done, finishing with resolving of cyclic messages", slog.Int("count", nassigned), slog.Int("unresolved", len(pending)))
|
||||
|
||||
if _, err := fmt.Fprintf(progressWriter, "assigning threads, resolving %d cyclic pending message-ids\n", len(pending)); err != nil {
|
||||
if _, err := fmt.Fprintf(xprogressWriter, "assigning threads, resolving %d cyclic pending message-ids\n", len(pending)); err != nil {
|
||||
return fmt.Errorf("writing progress: %v", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user