diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-07-26 13:48:27 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-26 22:22:58 +0200 |
commit | 26b9c3d9665db0d5a7990f75fc1baccc0139e7a5 (patch) | |
tree | 43aa32aa01cd9acc4b088020b6a2e2e28f79faa2 | |
parent | cfbb548fb86fb81b69809f9f1b68bbb60e823a40 (diff) | |
download | aerc-26b9c3d9665db0d5a7990f75fc1baccc0139e7a5.tar.gz |
sort: show warning when sort is not supported
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>
-rw-r--r-- | commands/account/sort.go | 6 | ||||
-rw-r--r-- | lib/msgstore.go | 5 | ||||
-rw-r--r-- | worker/imap/open.go | 2 |
3 files changed, 13 insertions, 0 deletions
diff --git a/commands/account/sort.go b/commands/account/sort.go index e9ee4a34..f8cb94c1 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 783ce5d0..c9f8fd91 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -847,3 +847,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 636b936c..2d76f43e 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) } |