aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorKevin Kuehler <keur@ocf.berkeley.edu>2019-07-14 00:42:24 -0700
committerDrew DeVault <sir@cmpwn.com>2019-07-15 09:46:49 -0400
commit8bb115dbae928111be52ed422dafb1caf72a744c (patch)
tree204da9d491c9fecb87d8ff946fb0ac80a9ac2f85 /commands
parentd85f671bdf90dbdd725db88e5d6970630e36f9f1 (diff)
downloadaerc-8bb115dbae928111be52ed422dafb1caf72a744c.tar.gz
commands: Don't crash when store is nil
On a slow network connection, running these commands without this guard will cause aerc to panic. Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
Diffstat (limited to 'commands')
-rw-r--r--commands/account/search.go3
-rw-r--r--commands/msg/archive.go5
-rw-r--r--commands/msg/copy.go5
-rw-r--r--commands/msg/delete.go3
-rw-r--r--commands/msg/move.go5
-rw-r--r--commands/msg/pipe.go3
-rw-r--r--commands/msg/read.go5
-rw-r--r--commands/msg/reply.go3
8 files changed, 28 insertions, 4 deletions
diff --git a/commands/account/search.go b/commands/account/search.go
index a8640dcc..0687c5b3 100644
--- a/commands/account/search.go
+++ b/commands/account/search.go
@@ -51,6 +51,9 @@ func (_ SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("No account selected")
}
store := acct.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
aerc.SetStatus("Searching...")
store.Search(criteria, func(uids []uint32) {
aerc.SetStatus("Search complete.")
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index fe391d28..63d6de08 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -41,11 +41,14 @@ func (_ Archive) Execute(aerc *widgets.Aerc, args []string) error {
if acct == nil {
return errors.New("No account selected")
}
+ store := widget.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
msg, err := widget.SelectedMessage()
if err != nil {
return err
}
- store := widget.Store()
archiveDir := acct.AccountConfig().Archive
store.Next()
acct.Messages().Scroll()
diff --git a/commands/msg/copy.go b/commands/msg/copy.go
index 48bccd4d..6bf33cd7 100644
--- a/commands/msg/copy.go
+++ b/commands/msg/copy.go
@@ -44,11 +44,14 @@ func (_ Copy) Execute(aerc *widgets.Aerc, args []string) error {
}
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
+ store := widget.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
msg, err := widget.SelectedMessage()
if err != nil {
return err
}
- store := widget.Store()
store.Copy([]uint32{msg.Uid}, args[optind], createParents, func(
msg types.WorkerMessage) {
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 36b8d8cf..55d7f685 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -35,6 +35,9 @@ func (_ Delete) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("No account selected")
}
store := widget.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
msg, err := widget.SelectedMessage()
if err != nil {
return err
diff --git a/commands/msg/move.go b/commands/msg/move.go
index 8b19a101..45fa6355 100644
--- a/commands/msg/move.go
+++ b/commands/msg/move.go
@@ -49,11 +49,14 @@ func (_ Move) Execute(aerc *widgets.Aerc, args []string) error {
if acct == nil {
return errors.New("No account selected")
}
+ store := widget.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
msg, err := widget.SelectedMessage()
if err != nil {
return err
}
- store := widget.Store()
_, isMsgView := widget.(*widgets.MessageViewer)
if isMsgView {
aerc.RemoveTab(widget)
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 821f3591..77e5d961 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -112,6 +112,9 @@ func (_ Pipe) Execute(aerc *widgets.Aerc, args []string) error {
if pipeFull {
store := provider.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
msg, err := provider.SelectedMessage()
if err != nil {
return err
diff --git a/commands/msg/read.go b/commands/msg/read.go
index 30c6822d..c6bd0982 100644
--- a/commands/msg/read.go
+++ b/commands/msg/read.go
@@ -30,11 +30,14 @@ func (_ Read) Execute(aerc *widgets.Aerc, args []string) error {
}
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
+ store := widget.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
msg, err := widget.SelectedMessage()
if err != nil {
return err
}
- store := widget.Store()
store.Read([]uint32{msg.Uid}, args[0] == "read", func(
msg types.WorkerMessage) {
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 5295ee6c..85c5d3ab 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -60,6 +60,9 @@ func (_ reply) Execute(aerc *widgets.Aerc, args []string) error {
conf := acct.AccountConfig()
us, _ := gomail.ParseAddress(conf.From)
store := widget.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
msg, err := widget.SelectedMessage()
if err != nil {
return err