kiss: fix quadratic behaviour (#91)

Not really necessary considering it occurs only when files are actually invalid

Example with manually broken linux package:

```
λ time ./kiss i linux > /dev/null
-> linux Checking if manifest valid
ERROR linux manifest contains 16997 non-existent files
Command exited with non-zero status 1
real	0m 0.57s
user	0m 0.15s
sys	0m 0.42s
```

```
λ time kiss i linux > /dev/null
-> linux Checking if manifest valid
ERROR linux manifest contains 16997 non-existent files
Command exited with non-zero status 1
real	1m 10.04s
user	1m 7.94s
sys	0m 2.08s
```

Co-authored-by: git-bruh <e817509a-8ee9-4332-b0ad-3a6bdf9ab63f@aleeas.com>
Reviewed-on: https://codeberg.org/kiss-community/kiss/pulls/91
This commit is contained in:
Pratham 2022-10-21 09:47:38 +02:00
parent 9c72484a62
commit 74f78a8529

9
kiss
View File

@ -898,16 +898,17 @@ pkg_manifest_validate() {
# NOTE: _pkg comes from caller.
log "$_pkg" "Checking if manifest valid"
cnt=0
while read -r line; do
[ -e "$tar_dir/$_pkg$line" ] || [ -h "$tar_dir/$_pkg$line" ] || {
printf '%s\n' "$line"
set -- "$@" "$line"
: $((cnt += 1))
}
done < "$pkg_db/$_pkg/manifest"
for f do
die "$_pkg" "manifest contains $# non-existent files"
done
equ "$cnt" 0 ||
die "$_pkg" "manifest contains $cnt non-existent files"
}
pkg_manifest_replace() {