Skip to content

Commit

Permalink
lint: naked error
Browse files Browse the repository at this point in the history
  • Loading branch information
gak committed Aug 20, 2024
1 parent 937456b commit 34eea87
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions backend/controller/dal/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ func (d *DAL) verifyEncryptor(ctx context.Context) (err error) {
var tx *Tx
tx, err = d.Begin(ctx)
if err != nil {
err = fmt.Errorf("failed to begin transaction: %w", err)
return
return fmt.Errorf("failed to begin transaction: %w", err)
}
defer tx.CommitOrRollback(ctx, &err)

Expand All @@ -108,31 +107,26 @@ func (d *DAL) verifyEncryptor(ctx context.Context) (err error) {
if err != nil {
if dal.IsNotFound(err) {
// No encryption key found, probably using noop.
err = nil
return
} else {
err = fmt.Errorf("failed to get encryption row from the db: %w", err)
return
return nil
}
return fmt.Errorf("failed to get encryption row from the db: %w", err)
}

up := false
up, err = verifySubkey(d.encryptor, row.VerifyTimeline)
if err != nil {
err = fmt.Errorf("failed to verify timeline subkey: %w", err)
return
return fmt.Errorf("failed to verify timeline subkey: %w", err)
}
needsUpdate := up

up, err = verifySubkey(d.encryptor, row.VerifyAsync)
if err != nil {
err = fmt.Errorf("failed to verify async subkey: %w", err)
return
return fmt.Errorf("failed to verify async subkey: %w", err)
}
needsUpdate = needsUpdate || up

if !needsUpdate {
return
return nil
}

if !row.VerifyTimeline.Ok() || !row.VerifyAsync.Ok() {
Expand All @@ -141,11 +135,10 @@ func (d *DAL) verifyEncryptor(ctx context.Context) (err error) {

err = tx.db.UpdateEncryptionVerification(ctx, row.VerifyTimeline, row.VerifyAsync)
if err != nil {
err = fmt.Errorf("failed to update encryption verification: %w", err)
return
return fmt.Errorf("failed to update encryption verification: %w", err)
}

return
return nil
}

// verifySubkey checks if the subkey is set and if not, sets it to a verification string.
Expand Down

0 comments on commit 34eea87

Please sign in to comment.