Skip to content

Commit

Permalink
なおした
Browse files Browse the repository at this point in the history
  • Loading branch information
a01sa01to committed Nov 25, 2023
1 parent 55b0ebf commit 292a16e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions go/user_handler.go
Expand Up @@ -453,18 +453,18 @@ func fillUserResponse(ctx context.Context, tx *sqlx.Tx, userModel UserModel) (Us
copy(iconHash[:], cachedbyte)
}

var image []byte
if err := tx.GetContext(ctx, &image, "SELECT image FROM icons WHERE user_id = ?", userModel.ID); err != nil {
if !errors.Is(err, sql.ErrNoRows) {
return User{}, err
}
image, err = os.ReadFile(fallbackImage)
if err != nil {
return User{}, err
if iconHash == [32]byte{} {
var image []byte
if err := tx.GetContext(ctx, &image, "SELECT image FROM icons WHERE user_id = ?", userModel.ID); err != nil {
if !errors.Is(err, sql.ErrNoRows) {
return User{}, err
}
image, err = os.ReadFile(fallbackImage)
if err != nil {
return User{}, err
}
}
}

if iconHash == [32]byte{} {
iconHash = sha256.Sum256(image)
userImageHashCache.Set(userModel.ID, fmt.Sprintf("%x", iconHash))
}
Expand Down

0 comments on commit 292a16e

Please sign in to comment.