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
7e8011ce29
commit
7e7c8ed274
1 changed files with 6 additions and 6 deletions
12
internal/cache/sqlite/sqlite.go
vendored
12
internal/cache/sqlite/sqlite.go
vendored
|
|
@ -62,8 +62,8 @@ func InsertScannedAssets(path string, assets ...magellan.RemoteAsset) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteScannedAssets(path string, results ...magellan.RemoteAsset) error {
|
func DeleteScannedAssets(path string, assets ...magellan.RemoteAsset) error {
|
||||||
if results == nil {
|
if assets == nil {
|
||||||
return fmt.Errorf("no assets found")
|
return fmt.Errorf("no assets found")
|
||||||
}
|
}
|
||||||
db, err := sqlx.Open("sqlite3", path)
|
db, err := sqlx.Open("sqlite3", path)
|
||||||
|
|
@ -71,11 +71,11 @@ func DeleteScannedAssets(path string, results ...magellan.RemoteAsset) error {
|
||||||
return fmt.Errorf("failed to open database: %v", err)
|
return fmt.Errorf("failed to open database: %v", err)
|
||||||
}
|
}
|
||||||
tx := db.MustBegin()
|
tx := db.MustBegin()
|
||||||
for _, state := range results {
|
for _, asset := range assets {
|
||||||
sql := fmt.Sprintf(`DELETE FROM %s WHERE host = :host, port = :port;`, TABLE_NAME)
|
sql := fmt.Sprintf(`DELETE FROM %s WHERE host=:host AND port=:port;`, TABLE_NAME)
|
||||||
_, err := tx.NamedExec(sql, &state)
|
_, err := tx.NamedExec(sql, &asset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("failed to execute transaction: %v\n", err)
|
fmt.Printf("failed to execute DELETE transaction: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue