1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-02 10:56:25 -07:00

Fix error log being written to even if there were no errors

This commit is contained in:
Eggbertx 2024-05-29 12:13:20 -07:00
parent 4613bea216
commit f72435ec8d
2 changed files with 9 additions and 4 deletions

View file

@ -308,15 +308,16 @@ func BuildBoards(verbose bool, which ...int) error {
}
var wg sync.WaitGroup
var tmpErr error
wg.Add(len(boards))
for b := range boards {
go func(board *gcsql.Board) {
tmpErr := buildBoard(board, true)
tmpErr = buildBoard(board, true)
if tmpErr == nil && verbose {
gcutil.LogInfo().Str("board", board.Dir).
Msg("Built board successfully")
} else if err == nil {
}
if err == nil && tmpErr != nil {
gcutil.LogError(err).Caller().Str("board", board.Dir).Msg("Unable to build board")
err = tmpErr
}

View file

@ -1,6 +1,7 @@
package gcsql
import (
"context"
"database/sql"
"errors"
"fmt"
@ -354,7 +355,10 @@ func (p *Post) Insert(bumpThread bool, boardID int, locked bool, stickied bool,
VALUES(?,?,PARAM_ATON,CURRENT_TIMESTAMP,?,?,?,?,?,?,?,?,?,?)`
bumpSQL := `UPDATE DBPREFIXthreads SET last_bump = CURRENT_TIMESTAMP WHERE id = ?`
tx, err := BeginTx()
ctx, cancel := context.WithTimeout(context.Background(), gcdb.defaultTimeout)
defer cancel()
tx, err := BeginContextTx(ctx)
if err != nil {
return err
}