Move defer and add a debug print

This commit is contained in:
Tulir Asokan 2018-04-30 12:01:24 +03:00
parent d1b62b854c
commit 74119ee242

View File

@ -59,10 +59,7 @@ func (msg *ImageMessage) RegisterMatrix(matrix ifc.MatrixContainer) {
msg.matrix = matrix
if len(msg.data) == 0 {
go func() {
defer debug.Recover()
msg.updateData()
}()
go msg.updateData()
}
}
@ -71,12 +68,14 @@ func (msg *ImageMessage) NotificationContent() string {
}
func (msg *ImageMessage) updateData() {
defer debug.Recover()
debug.Print("Loading image:", msg.Homeserver, msg.FileID)
data, _, _, err := msg.matrix.Download(fmt.Sprintf("mxc://%s/%s", msg.Homeserver, msg.FileID))
if err != nil {
debug.Print("Failed to download image %s/%s: %v", msg.Homeserver, msg.FileID, err)
return
}
debug.Print("Image", msg.Homeserver, msg.FileID, "loaded.")
msg.data = data
}