<commit_before>package imap

import (
	"bytes"
	"io/ioutil"

	"github.com/emersion/neutron/backend"
	"github.com/mxk/go-imap/imap"
)

func (b *Messages) ReadAttachment(user, id string) (att *backend.Attachment, out []byte, err error) {
	mailbox, uid, partId, err := parseAttachmentId(id)
	if err != nil {
		return
	}

	err = b.selectMailbox(user, mailbox)
	if err != nil {
		return
	}

	c, unlock, err := b.getConn(user)
	if err != nil {
		return
	}
	defer unlock()

	seqset, _ := imap.NewSeqSet("")
	seqset.AddNum(uid)

	cmd, _, err := wait(c.UIDFetch(seqset, "BODYSTRUCTURE", "BODY.PEEK["+partId+"]"))
	if err != nil {
		return
	}

	rsp := cmd.Data[0]
	msgInfo := rsp.MessageInfo()
	structure := parseBodyStructure(imap.AsList(msgInfo.Attrs["BODYSTRUCTURE"]))
	body := imap.AsBytes(msgInfo.Attrs["BODY["+partId+"]"])

	part := structure.Get(partId)
	att = part.Attachment()
	r := part.DecodeContent(bytes.NewReader(body))
	out, err = ioutil.ReadAll(r)
	return
}<commit_msg>Adds placeholders for missing attachments methods in imap backend<commit_after>package imap

import (
	"bytes"
	"errors"
	"io/ioutil"

	"github.com/emersion/neutron/backend"
	"github.com/mxk/go-imap/imap"
)

func (b *Messages) ReadAttachment(user, id string) (att *backend.Attachment, out []byte, err error) {
	mailbox, uid, partId, err := parseAttachmentId(id)
	if err != nil {
		return
	}

	err = b.selectMailbox(user, mailbox)
	if err != nil {
		return
	}

	c, unlock, err := b.getConn(user)
	if err != nil {
		return
	}
	defer unlock()

	seqset, _ := imap.NewSeqSet("")
	seqset.AddNum(uid)

	cmd, _, err := wait(c.UIDFetch(seqset, "BODYSTRUCTURE", "BODY.PEEK["+partId+"]"))
	if err != nil {
		return
	}

	rsp := cmd.Data[0]
	msgInfo := rsp.MessageInfo()
	structure := parseBodyStructure(imap.AsList(msgInfo.Attrs["BODYSTRUCTURE"]))
	body := imap.AsBytes(msgInfo.Attrs["BODY["+partId+"]"])

	part := structure.Get(partId)
	att = part.Attachment()
	r := part.DecodeContent(bytes.NewReader(body))
	out, err = ioutil.ReadAll(r)
	return
}

func (b *Messages) InsertAttachment(user string, attachment *backend.Attachment, contents []byte) (*backend.Attachment, error) {
	return nil, errors.New("Not yet implemented")
}

func (b *Messages) DeleteAttachment(user, id string) error {
	return errors.New("Not yet implemented")
}
{'fraction_non_alphanumeric': 0.16412712233347845, 'fraction_numerical': 0.0008707009142359599, 'mean_word_length': 4.6600985221674875, 'pattern_counts': {'":': 0, '<': 3, '<?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': '488428', 'n_tokens_mistral': 904, 'n_tokens_neox': 889, 'n_words': 186}