git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Teach mailsplit about Maildir's

From
FPFernando J. Pereda <ferdy@gentoo.org>
Date
Apr 27, 2007, 08:59 UTC
Message-ID
<20070427085951.GC4690@ferdyx.org>
In-Reply-To
<7vd51qp57k.fsf@assigned-by-dhcp.cox.net>
On Fri, Apr 27, 2007 at 01:54:55AM -0700, Junio C Hamano wrote:
Show 38 quoted lines
> "Fernando J. Pereda" <ferdy@gentoo.org> writes:
> 
> > +int split_maildir(const char *maildir, const char *dir, int nr_prec, int skip)
> >  {
> > ...
> > +	while ((maildent = readdir(mddir)) != NULL) {
> > +		FILE *f;
> > +
> > +		snprintf(file, sizeof(file), "%s/%s",
> > +				curdir, maildent->d_name);
> > +
> > +		if (maildent->d_name[0] == '.')
> > +			continue;
> >  ...
> > +		sprintf(name, "%s/%0*d", dir, nr_prec, ++skip);
> > +		split_one(f, name, 1);
> > +
> > +		fclose(f);
> > +	}
> > +
> > +	closedir(mddir);
> > +
> > +	ret = skip;
> > +out:
> > +	return ret;
> > +}
> 
> I do not personally deal with maildir so I do not know for sure,
> but this feels very wrong.
> 
> What order are you emitting the output?
> 
> split_mbox() is designed to number the messages the same order
> as they are found in the mailbox, but the above loop relies on
> readdir() to give them in a reasonable order to you, which does
> not seem a right assumption to me (otherwise "/bin/ls" and
> friends would not sort what they read from the filesystem would
> they?).

It is indeed very wrong. You can't sort them without opening and parsing the headers. Please drop this patch.

Sorry for the noise.
- ferdy
-- 
Fernando J. Pereda Garcimartín
20BB BDC3 761A 4781 E6ED  ED0B 0A48 5B0C 60BD 28D4
Previous: Junio C Hamano
Message 4 of 4 in “Teach mailsplit about Maildir's”
  1. Teach mailsplit about Maildir'sFernando J. Pereda, Apr 26, 2007
  2. Fernando J. PeredaApr 27, 2007
  3. Junio C HamanoApr 27, 2007
  4. Fernando J. PeredaApr 27, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.