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>
This commit is contained in:
parent
cfbb548fb8
commit
26b9c3d966
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue