mirror of
https://github.com/Jguer/yay.git
synced 2025-12-27 07:35:48 -05:00
fix(main): return 1 exit code on panic (#2590)
This commit is contained in:
@@ -43,6 +43,10 @@ func srcinfoExists(ctx context.Context,
|
|||||||
return fmt.Errorf("unable to generate .SRCINFO: %w - %s", err, stderr)
|
return fmt.Errorf("unable to generate .SRCINFO: %w - %s", err, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(srcinfo) == 0 {
|
||||||
|
return fmt.Errorf("generated .SRCINFO is empty, check your PKGBUILD for errors")
|
||||||
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(srcInfoDir, []byte(srcinfo), 0o600); err != nil {
|
if err := os.WriteFile(srcInfoDir, []byte(srcinfo), 0o600); err != nil {
|
||||||
return fmt.Errorf("unable to write .SRCINFO: %w", err)
|
return fmt.Errorf("unable to write .SRCINFO: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -47,8 +47,9 @@ func main() {
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if rec := recover(); rec != nil {
|
if rec := recover(); rec != nil {
|
||||||
fallbackLog.Errorln(rec)
|
fallbackLog.Errorln("Panic occurred:", rec)
|
||||||
debug.PrintStack()
|
fallbackLog.Errorln("Stack trace:", string(debug.Stack()))
|
||||||
|
ret = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(ret)
|
os.Exit(ret)
|
||||||
@@ -122,7 +123,8 @@ func main() {
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if rec := recover(); rec != nil {
|
if rec := recover(); rec != nil {
|
||||||
fallbackLog.Errorln(rec, string(debug.Stack()))
|
fallbackLog.Errorln("Panic occurred in DB operation:", rec)
|
||||||
|
fallbackLog.Errorln("Stack trace:", string(debug.Stack()))
|
||||||
}
|
}
|
||||||
|
|
||||||
dbExecutor.Cleanup()
|
dbExecutor.Cleanup()
|
||||||
|
|||||||
6
vcs.go
6
vcs.go
@@ -61,8 +61,8 @@ func createDevelDB(ctx context.Context, run *runtime.Runtime, dbExecutor db.Exec
|
|||||||
for iP := range srcinfos[i].Packages {
|
for iP := range srcinfos[i].Packages {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
go func(i string, iP int) {
|
go func(baseIndex string, packageIndex int) {
|
||||||
run.VCSStore.Update(ctx, srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source)
|
run.VCSStore.Update(ctx, srcinfos[baseIndex].Packages[packageIndex].Pkgname, srcinfos[baseIndex].Source)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(i, iP)
|
}(i, iP)
|
||||||
}
|
}
|
||||||
@@ -71,5 +71,5 @@ func createDevelDB(ctx context.Context, run *runtime.Runtime, dbExecutor db.Exec
|
|||||||
wg.Wait()
|
wg.Wait()
|
||||||
run.Logger.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
|
run.Logger.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
|
||||||
|
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user