<commit_before>package responses

import (
	"github.com/emersion/go-imap"
)

// A SELECT response.
type Select struct {
	Mailbox *imap.MailboxStatus
}

func (r *Select) HandleFrom(hdlr imap.RespHandler) (err error) {
	if r.Mailbox == nil {
		r.Mailbox = &imap.MailboxStatus{}
	}
	mbox := r.Mailbox

	mbox.Items = make(map[string]interface{})
	for h := range hdlr {
		switch res := h.Resp.(type) {
		case *imap.Resp:
			fields, ok := h.AcceptNamedResp(imap.MailboxFlags)
			if !ok {
				break
			}

			flags, _ := fields[0].([]interface{})
			mbox.Flags, _ = imap.ParseStringList(flags)
			mbox.Items[imap.MailboxFlags] = nil
		case *imap.StatusResp:
			if len(res.Arguments) < 1 {
				h.Accepts <- false
				break
			}

			accepted := true
			switch res.Code {
			case imap.MailboxUnseen:
				mbox.Unseen, _ = imap.ParseNumber(res.Arguments[0])
				mbox.ItemsLocker.Lock()
				mbox.Items[imap.MailboxUnseen] = nil
				mbox.ItemsLocker.Unlock()
			case imap.MailboxPermanentFlags:
				flags, _ := res.Arguments[0].([]interface{})
				mbox.PermanentFlags, _ = imap.ParseStringList(flags)
				mbox.ItemsLocker.Lock()
				mbox.Items[imap.MailboxPermanentFlags] = nil<commit_msg>One more write to protect<commit_after>package responses

import (
	"github.com/emersion/go-imap"
)

// A SELECT response.
type Select struct {
	Mailbox *imap.MailboxStatus
}

func (r *Select) HandleFrom(hdlr imap.RespHandler) (err error) {
	if r.Mailbox == nil {
		r.Mailbox = &imap.MailboxStatus{}
	}
	mbox := r.Mailbox

	mbox.Items = make(map[string]interface{})
	for h := range hdlr {
		switch res := h.Resp.(type) {
		case *imap.Resp:
			fields, ok := h.AcceptNamedResp(imap.MailboxFlags)
			if !ok {
				break
			}

			flags, _ := fields[0].([]interface{})
			mbox.Flags, _ = imap.ParseStringList(flags)
			mbox.ItemsLocker.Lock()
			mbox.Items[imap.MailboxFlags] = nil
			mbox.ItemsLocker.Unlock()
		case *imap.StatusResp:
			if len(res.Arguments) < 1 {
				h.Accepts <- false
				break
			}

			accepted := true
			switch res.Code {
			case imap.MailboxUnseen:
				mbox.Unseen, _ = imap.ParseNumber(res.Arguments[0])
				mbox.ItemsLocker.Lock()
				mbox.Items[imap.MailboxUnseen] = nil
				mbox.ItemsLocker.Unlock()
			case imap.MailboxPermanentFlags:
				flags, _ := res.Arguments[0].([]interface{})
				mbox.PermanentFlags, _ = imap.ParseStringList(flags)
				mbox.ItemsLocker.Lock()
				mbox.Items[imap.MailboxPermanentFlags] = nil
{'fraction_non_alphanumeric': 0.13990066225165562, 'fraction_numerical': 0.0033112582781456954, 'mean_word_length': 3.434862385321101, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4290736', 'n_tokens_mistral': 1033, 'n_tokens_neox': 880, 'n_words': 161}