Fix a bunch of not-checking-error lints

This commit is contained in:
Eli Ribble 2026-05-04 20:29:02 +00:00
parent 114aec73ed
commit 5f3fcc2b3e
No known key found for this signature in database
14 changed files with 124 additions and 34 deletions

View file

@ -99,7 +99,7 @@ func LoadTemplates() error {
if err != nil {
return fmt.Errorf("Failed to load report-notification-confirmation template ID: %s", err)
}
tx.Commit(ctx)
lint.LogOnErrCtx(tx.Commit, ctx, "commit")
return nil
}

View file

@ -7,6 +7,7 @@ import (
"os"
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/google/uuid"
//"github.com/rs/zerolog/log"
)
@ -93,7 +94,7 @@ func writeFileContent(w http.ResponseWriter, image_path string) {
}
return
}
defer file.Close()
defer lint.LogOnErr(file.Close, "close file")
// Get file info for Content-Length header
fileInfo, err := file.Stat()

View file

@ -6,6 +6,7 @@ import (
"net/http"
"os"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
)
@ -18,7 +19,7 @@ func ImageFileFromReader(collection Collection, uid uuid.UUID, body io.Reader) e
if err != nil {
return fmt.Errorf("Failed to create image file %s: %w", filepath, err)
}
defer dst.Close()
defer lint.LogOnErr(dst.Close, "close dst file")
// Copy rest of request body to file
_, err = io.Copy(dst, body)

View file

@ -5,6 +5,7 @@ import (
"io"
"os"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/rs/zerolog/log"
)
@ -16,7 +17,7 @@ func MailerFromReader(public_id string, body io.Reader) error {
if err != nil {
return fmt.Errorf("Failed to create image file %s: %w", filepath, err)
}
defer dst.Close()
defer lint.LogOnErr(dst.Close, "close dst file")
// Copy rest of request body to file
_, err = io.Copy(dst, body)

View file

@ -7,6 +7,7 @@ import (
"mime/multipart"
"net/http"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
)
@ -50,7 +51,7 @@ func saveFileUpload(headers *multipart.FileHeader, collection Collection) (uploa
if err != nil {
return upload, fmt.Errorf("Failed to open header: %w", err)
}
defer file.Close()
defer lint.LogOnErr(file.Close, "close file")
file_bytes, err := io.ReadAll(file)
content_type := http.DetectContentType(file_bytes)

View file

@ -7,6 +7,7 @@ import (
"os"
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
)
@ -33,7 +34,7 @@ func FileContentWrite(body io.Reader, collection Collection, uid uuid.UUID) erro
log.Error().Err(err).Str("filepath", filepath).Msg("Failed to create upload file")
return fmt.Errorf("Failed to create upload file at %s: %v", filepath, err)
}
defer dst.Close()
defer lint.LogOnErr(dst.Close, "close dst file")
// Copy rest of request body to file
_, err = io.Copy(dst, body)

View file

@ -9,6 +9,7 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/Gleipnir-Technology/nidus-sync/lob"
"github.com/Gleipnir-Technology/nidus-sync/platform/file"
"github.com/Gleipnir-Technology/nidus-sync/platform/pdf"
@ -91,7 +92,7 @@ func ComplianceSend(ctx context.Context, row_id int32) error {
if err != nil {
return fmt.Errorf("start txn: %w", err)
}
defer txn.Rollback(ctx)
defer lint.LogOnErrRollback(txn.Rollback, ctx, "rollback")
mailer, err := models.CommsMailers.Insert(&models.CommsMailerSetter{
AddressID: omit.From(address.ID),
Created: omit.From(time.Now()),
@ -113,7 +114,7 @@ func ComplianceSend(ctx context.Context, row_id int32) error {
return fmt.Errorf("create crrm: %w", err)
}
log.Info().Int32("id", crrm.ID).Msg("Created compliance report request mailer")
txn.Commit(ctx)
lint.LogOnErrCtx(txn.Commit, ctx, "commit")
return nil
}

View file

@ -44,7 +44,10 @@ func ClearOauth(ctx context.Context, user *models.User) {
models.UpdateWhere.Notifications.UserID.EQ(user.ID),
setter.UpdateMod(),
)
updater.Exec(ctx, db.PGInstance.BobDB)
_, err := updater.Exec(ctx, db.PGInstance.BobDB)
if err != nil {
log.Error().Err(err).Msg("execute update")
}
//user.UserNotifications(
//models.SelectWhere.Notifications.Link.EQ(NotificationPathOauthReset),
//).UpdateAll()