Implement UDP socket server and add package installation check utility

This commit is contained in:
2025-09-21 10:34:49 -03:00
parent 68b394523d
commit f34308367e
4 changed files with 141 additions and 4 deletions

View File

@@ -239,3 +239,19 @@ func (p *Package) AddToInstalledDB(inCache int, packagePath string) error {
success = true
return err
}
func CheckIfPackageInstalled(name string) (bool, error) {
db, err := sql.Open("sqlite", consts.InstalledDB)
if err != nil {
return false, err
}
defer db.Close()
var exists bool
err = db.QueryRow("SELECT EXISTS(SELECT 1 FROM packages WHERE name = ?)", name).Scan(&exists)
if err != nil {
return false, err
}
return exists, nil
}