repo-add: unconditionally create the database if it is missing

In f91fa546 (repo-add: do not recreate the database if nothing was changed),
repo-add was made to skip database write-out if there were no changes to
the database. However, this breaks the usage of repo-add to create a new
empty database: `repo-add /path/to/mydb/mydb.db.tar.xz`.

Bring back support for this use-case by always writing the database if
it is missing.

Original-patch-by: Ivan Shapovalov <intelfx@intelfx.name>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2024-06-20 13:21:16 +10:00
parent 3f1943c84d
commit 8d14b22260

View file

@ -705,7 +705,7 @@ if (( fail )); then
exit 1
fi
if (( DB_MODIFIED )); then
if (( DB_MODIFIED )) || [[ ! -f $REPO_DB_FILE ]]; then
msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
create_db
rotate_db