~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH aerc] sort: show warning when sort is not supported

Details
Message ID
<20220726114827.2274973-1-koni.marti@gmail.com>
DKIM signature
missing
Download raw message
Patch: +13 -0
Use the capabilities returned by the backend to check whether sort is
implemented when the user tries to use the sort command. Print a warning
to the log when a sort request is silently dropped by the backend.

Suggested-by: |cos|
Signed-off-by: Koni Marti <koni.marti@gmail.com>
---
 commands/account/sort.go | 6 ++++++
 lib/msgstore.go          | 5 +++++
 worker/imap/open.go      | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/commands/account/sort.go b/commands/account/sort.go
index e9ee4a3..f8cb94c 100644
--- a/commands/account/sort.go
+++ b/commands/account/sort.go
@@ -72,6 +72,12 @@ func (Sort) Execute(aerc *widgets.Aerc, args []string) error {
		return errors.New("Messages still loading.")
	}

	if c := store.Capabilities(); c != nil {
		if !c.Sort {
			return errors.New("Sorting is not available for this backend.")
		}
	}

	var err error
	var sortCriteria []*types.SortCriterion
	if len(args[1:]) == 0 {
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 61a6dd4..c79145e 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -801,3 +801,8 @@ func (store *MessageStore) FindIndexByUid(uid uint32) int {
	}
	return -1
}

// Capabilities returns a models.Capabilities struct or nil if not available
func (store *MessageStore) Capabilities() *models.Capabilities {
	return store.DirInfo.Caps
}
diff --git a/worker/imap/open.go b/worker/imap/open.go
index 636b936..2d76f43 100644
--- a/worker/imap/open.go
+++ b/worker/imap/open.go
@@ -53,6 +53,8 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
		if err != nil {
			// Non fatal, but we do want to print to get some debug info
			logging.Errorf("can't check for SORT support: %v", err)
		} else if len(sortCriteria) > 0 {
			logging.Warnf("SORT is not supported but requested: list messages by UID")
		}
		uids, err = imapw.client.UidSearch(searchCriteria)
	}
-- 
2.36.1

[aerc/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CLPKDVAO85TF.17EPAQNN4DKXX@cirno>
In-Reply-To
<20220726114827.2274973-1-koni.marti@gmail.com> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: SUCCESS in 2m48s

[sort: show warning when sort is not supported][0] from [Koni Marti][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/34191
[1]: koni.marti@gmail.com

✓ #809698 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/809698
✓ #809697 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/809697
Details
Message ID
<CLPLVK8YIUWU.3V7VZ092697M4@nano>
In-Reply-To
<20220726114827.2274973-1-koni.marti@gmail.com> (view parent)
DKIM signature
missing
Download raw message
On Tue Jul 26, 2022 at 4:48 AM PDT, Koni Marti wrote:
> Use the capabilities returned by the backend to check whether sort is
> implemented when the user tries to use the sort command. Print a warning
> to the log when a sort request is silently dropped by the backend.
>
> Suggested-by: |cos|
> Signed-off-by: Koni Marti <koni.marti@gmail.com>

tested.  it works.

Acked-by: akspecs <akspecs@gmail.com>
Details
Message ID
<CLPVK3H7GEBO.1CRMMTNE8JKR7@marty>
In-Reply-To
<20220726114827.2274973-1-koni.marti@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Koni Marti, Jul 26, 2022 at 13:48:
> Use the capabilities returned by the backend to check whether sort is
> implemented when the user tries to use the sort command. Print a warning
> to the log when a sort request is silently dropped by the backend.
>
> Suggested-by: |cos|
> Signed-off-by: Koni Marti <koni.marti@gmail.com>

Acked-by: Robin-Jarry <robin@jarry.cc>

Applied on master. Thanks!
Reply to thread Export thread (mbox)