optimise sign

This commit is contained in:
ferrreo 2023-09-05 13:04:50 +01:00
parent d2023a5789
commit e323da1a41
3 changed files with 6 additions and 56 deletions

BIN
ppp

Binary file not shown.

View File

@ -128,61 +128,11 @@ func compare(basePackages map[string]packageInfo, targetPackages map[string]pack
} }
func signFiles(path string) { func signFiles(path string) {
ch := make(chan bool)
dir, err := os.Open(path) go func() {
if err != nil { sign(ch, path+"*.deb")
panic(err) }()
} <-ch
defer dir.Close()
files, err := dir.Readdirnames(-1)
if err != nil {
panic(err)
}
signQueue := make(chan string, 10)
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case path, ok := <-signQueue:
if !ok {
return
}
ch := make(chan bool)
go func() {
sign(ch, path)
}()
<-ch
default:
// No more files to sign, exit the goroutine
return
}
}
}()
}
count := 0
totalCount := len(files)
filePath := ""
for _, file := range files {
totalCount--
if count < 10 && totalCount > 0 {
count++
filePath = filePath + " " + path + file
} else {
count = 0
filePath = filePath + " " + path + file
signQueue <- filePath
}
}
close(signQueue)
wg.Wait()
} }
func sign(ch chan bool, path string) { func sign(ch chan bool, path string) {

View File

@ -39,7 +39,7 @@ echo "Getting ubuntu main pool 64bit"
cd ../ cd ../
if [ $(ls | wc -l) -l 1 ]; then if [ $(ls ./output/ | wc -l) -l 1 ]; then
echo "Repos are synced" echo "Repos are synced"
exit 0 exit 0
fi fi