mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Changed DeleteScannedAssets to work correct and added db tag
This commit is contained in:
parent
738685095f
commit
0f811543f5
1 changed files with 1 additions and 17 deletions
18
internal/cache/sqlite/sqlite.go
vendored
18
internal/cache/sqlite/sqlite.go
vendored
|
|
@ -2,7 +2,6 @@ package sqlite
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/OpenCHAMI/magellan/internal/util"
|
||||
magellan "github.com/OpenCHAMI/magellan/pkg"
|
||||
|
|
@ -78,22 +77,7 @@ func DeleteScannedAssets(path string, assets ...magellan.RemoteAsset) error {
|
|||
}
|
||||
tx = db.MustBegin()
|
||||
for _, asset := range assets {
|
||||
// skip if neither host nor port are specified
|
||||
if asset.Host == "" && asset.Port <= 0 {
|
||||
continue
|
||||
}
|
||||
sql := fmt.Sprintf(`DELETE FROM %s`, TABLE_NAME)
|
||||
where := []string{}
|
||||
if asset.Port > 0 {
|
||||
where = append(where, "port=:port")
|
||||
}
|
||||
if asset.Host != "" {
|
||||
where = append(where, "host=:host")
|
||||
}
|
||||
if len(where) <= 0 {
|
||||
continue
|
||||
}
|
||||
sql += fmt.Sprintf(" WHERE %s;", strings.Join(where, " AND "))
|
||||
sql := fmt.Sprintf(`DELETE FROM %s WHERE host=:host AND port=:port;`, TABLE_NAME)
|
||||
_, err := tx.NamedExec(sql, &asset)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to execute DELETE transaction: %v\n", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue