Add ed25519 public key and enhance package installation error handling

- Embed ed25519 public key for signature verification when doing sync prcess with servidordomal.fun
- Improve error handling in AddToInstalledDB to rollback on failure
- Update InstallPackage function to accept io.Reader instead of *os.File
This commit is contained in:
2025-09-20 21:55:34 -03:00
parent b14bd1806a
commit 68b394523d
4 changed files with 166 additions and 15 deletions

View File

@@ -204,6 +204,17 @@ func (p *Package) AddToInstalledDB(inCache int, packagePath string) error {
}
defer db.Close()
var success bool
defer func() {
if !success {
_, err := db.Exec("DELETE FROM packages WHERE name = ?", p.Manifest.Info.Name)
if err != nil {
log.Println("Failed to rollback package addition:", err)
}
}
}()
_, err = db.Exec(`
INSERT INTO packages (
query_name, name, version, dependencies, description,
@@ -222,5 +233,9 @@ func (p *Package) AddToInstalledDB(inCache int, packagePath string) error {
p.Arch,
inCache,
)
if err != nil {
return err
}
success = true
return err
}