Minor changes

This commit is contained in:
David Allen 2024-09-18 20:18:53 -06:00 committed by David Allen
parent d2bb3a94fe
commit 98ad63a797
Signed by: towk
GPG key ID: 0430CDBE22619155
2 changed files with 22 additions and 6 deletions

View file

@ -72,7 +72,13 @@ func DeleteScannedAssets(path string, assets ...magellan.RemoteAsset) error {
}
tx := db.MustBegin()
for _, asset := range assets {
sql := fmt.Sprintf(`DELETE FROM %s WHERE host=:host AND port=:port;`, TABLE_NAME)
if asset.Host == "" && asset.Port <= 0 {
continue
}
sql := fmt.Sprintf(`DELETE FROM %s WHERE port=:port;`, TABLE_NAME)
if asset.Host != "" {
sql += "AND host=:host"
}
_, err := tx.NamedExec(sql, &asset)
if err != nil {
fmt.Printf("failed to execute DELETE transaction: %v\n", err)