only write failed list if changed

This commit is contained in:
2021-08-26 13:56:02 +02:00
parent e835a54745
commit 10d777f3a9

View File

@@ -322,11 +322,13 @@ func isPkgFailed(pkg *BuildPackage) bool {
failed := false
var newContent []string
scanner := bufio.NewScanner(file)
found := false
for scanner.Scan() {
line := scanner.Text()
splitPkg := strings.Split(line, "==")
if splitPkg[0] == pkg.Pkgbase {
found = true
pkgVer := constructVersion(pkg.Srcinfo.Pkgver, pkg.Srcinfo.Pkgrel, pkg.Srcinfo.Epoch)
// try to build new versions of previously failed packages
@@ -340,15 +342,17 @@ func isPkgFailed(pkg *BuildPackage) bool {
newContent = append(newContent, line+"\n")
}
}
check(scanner.Err())
sort.Strings(newContent)
_, err = file.Seek(0, 0)
check(err)
check(file.Truncate(0))
_, err = file.WriteString(strings.Join(newContent, ""))
check(err)
if found {
sort.Strings(newContent)
_, err = file.Seek(0, 0)
check(err)
check(file.Truncate(0))
_, err = file.WriteString(strings.Join(newContent, ""))
check(err)
}
return failed
}