Skip to content

Commit

Permalink
remove unnecessary existance test
Browse files Browse the repository at this point in the history
  • Loading branch information
MalinAhlberg committed Oct 24, 2024
1 parent b9c8d3d commit 0f68dbe
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions sda/internal/database/db_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package database
import (
"encoding/hex"
"errors"
"fmt"
"math"
"strings"
"time"
Expand Down Expand Up @@ -788,14 +787,8 @@ func (dbs *SDAdb) SetKeyHash(keyHash, fileID string) error {
dbs.checkAndReconnectIfNeeded()
db := dbs.DB

query := `SELECT key_hash FROM sda.encryption_keys WHERE key_hash = $1;`
var hashID string
err := db.QueryRow(query, keyHash).Scan(&hashID)
if err != nil {
return fmt.Errorf("keyhash not present in database: %v", err)
}
query = "UPDATE sda.files SET key_hash = $1 WHERE id = $2;"
result, err := db.Exec(query, hashID, fileID)
query := "UPDATE sda.files SET key_hash = $1 WHERE id = $2;"
result, err := db.Exec(query, keyHash, fileID)
if err != nil {

return err
Expand Down

0 comments on commit 0f68dbe

Please sign in to comment.