Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message sort order when using maildir as storage. #124

Open
cspencer49519 opened this issue Nov 11, 2016 · 3 comments
Open

Message sort order when using maildir as storage. #124

cspencer49519 opened this issue Nov 11, 2016 · 3 comments
Labels

Comments

@cspencer49519
Copy link

When using maildir as my storage medium, all messages are sorted ascending, how can I get them to sort descending(most recent first)?

@ian-kent
Copy link
Member

That'd be a bug, of sorts. The maildir implementation returns messages in the order they're returned by the file system without any sorting.

Having just looked at the code, its even more basic than that - it returns all messages regardless of the start or limit values passed in.

Adding a sort would be easy, though inefficient for large numbers of messages (not that what's there now could be considered efficient). Start and limit would be a bit tougher, so maildir might only ever be useful for capturing message data rather than accessing it from the API or web UI.

@staabm
Copy link

staabm commented Oct 23, 2018

we also experience this problem with the maildir-based storage

eliasp added a commit to ssc-services/salt-formulas-public that referenced this issue Nov 30, 2018
The `maildir` backend sorts mails in the UI in the wrong order (old > new) instead of the other way round.
See also:
- mailhog/MailHog#124
@koshatul
Copy link

Just something as simple as:

	sort.Slice(n, func(i, j int) bool {
		return !n[i].ModTime().Before(n[j].ModTime())
	})

	if start < 0 {
		start = 0
	}

	if len(n) < start+limit {
		limit = len(n) - start
	}

	if len(n) > start && start > 0 {
		n = n[start:]
	}

	if len(n) > limit {
		n = n[:limit]
	}

in the storage/maildir.go would add date sorting by default and start/limit support, the overhead isn't that much more than what it currently has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants