Added log to debug an image store nil pointer panic

This commit is contained in:
Samuel Hawksby-Robinson 2020-11-12 11:36:32 +00:00 committed by Andrea Maria Piana
parent 056649fd73
commit 9545f8e306
3 changed files with 8 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/status-im/status-go/images"
"math/big"
"os"
@ -1307,6 +1308,9 @@ func (b *GethStatusBackend) StoreIdentityImage(filepath string, aX, aY, bX, bY i
return "", err
}
// TODO remove once debug has been resolved
b.log.Info("generated profile images", spew.Sdump(iis, aX, aY, bX, bY))
idb := images.NewDatabase(b.appDB)
err = idb.StoreIdentityImages(iis)
if err != nil {

View File

@ -87,7 +87,7 @@ func (d *Database) StoreIdentityImages(iis []*IdentityImage) (err error) {
defer stmt.Close()
for _, ii := range iis {
_, err = stmt.Exec(ii.Name, ii.Payload, ii.Width, ii.Height, ii.FileSize, ii.ResizeTarget)
_, err = stmt.Exec(&ii.Name, &ii.Payload, &ii.Width, &ii.Height, &ii.FileSize, &ii.ResizeTarget)
if err != nil {
return
}

View File

@ -113,7 +113,7 @@ func TestDatabase_GetIdentityImages(t *testing.T) {
defer stop()
seedTestDB(t, db)
expected := `[{"name":"large","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUg=","width":240,"height":300,"file_size":1024,"resize_target":240},{"name":"thumbnail","uri":"data:image/jpeg;base64,/9j/2wCEAFA3PEY8MlA=","width":80,"height":80,"file_size":256,"resize_target":80}]`
expected := `[{"type":"large","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUg=","width":240,"height":300,"file_size":1024,"resize_target":240},{"type":"thumbnail","uri":"data:image/jpeg;base64,/9j/2wCEAFA3PEY8MlA=","width":80,"height":80,"file_size":256,"resize_target":80}]`
oiis, err := db.GetIdentityImages()
require.NoError(t, err)
@ -134,11 +134,11 @@ func TestDatabase_GetIdentityImage(t *testing.T) {
}{
{
SmallDimName,
`{"name":"thumbnail","uri":"data:image/jpeg;base64,/9j/2wCEAFA3PEY8MlA=","width":80,"height":80,"file_size":256,"resize_target":80}`,
`{"type":"thumbnail","uri":"data:image/jpeg;base64,/9j/2wCEAFA3PEY8MlA=","width":80,"height":80,"file_size":256,"resize_target":80}`,
},
{
LargeDimName,
`{"name":"large","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUg=","width":240,"height":300,"file_size":1024,"resize_target":240}`,
`{"type":"large","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUg=","width":240,"height":300,"file_size":1024,"resize_target":240}`,
},
}