Race condition in db-update
In https://gitlab.archlinux.org/archlinux/dbscripts/-/blob/6db509332aab93489ca18e3b2d6f8628cde87f83/db-update#L37, db-update first calls getpkgfiles
to retrieve the package file list, to check if the packages are valid.
Then it moves the files by calling getpkgfiles
again in the following section. This unfortunately has a race-condition that the subsequent calls retrieves a different file list than the actually checked ones (for example, new packages uploaded to the staging folder right in between).
A real-world problem of this race condition is about split packages. Imagine we have a pkgbase that packages pkgname A and B. When db-update was running for another package C, it passes the checking section when the staging folder contains only package C. Then when it does the actual move, package A got uploaded to the folder and was moved together with package C. This left only package B in the staging folder and all subsequent calls to db-update will fail with "ERROR: Missing split packages for xxx".
An easy fix would be adding another check for the package in "${arch_pkgs[@]}" "${any_pkgs[@]}"
about whether they are the already checked pkgs
. Either error out or just ignore the unchecked packages should work when it doesn't.