[pacman-dev] [PATCH 2/2] Backup old database before updating and restore on failure

Allan McRae allan at archlinux.org
Mon Dec 16 23:30:33 UTC 2019


On 17/12/19 1:21 am, Eli Schwartz wrote:
> On 12/16/19 10:05 AM, Allan McRae wrote:
>> If alpm_db_update() fails due to an invalid signature, then the system
>> is left with an unusable repo database.  Instead, backup the currently
>> working database before performing the update, and restore on error.
>>
>> Note that the calls rename and unlink are not checked for errors. If these
>> fail, there is nothing to be done anyway.  It also allows for less complex
>> flow, as these function fail gracefully when passed NULL arguments.
>>
>> Signed-off-by: Allan McRae <allan at archlinux.org>
>> ---
>>
>> That is a lot of teduim for adding ".bak" to the end of a string...
>>
>> I'd appreciate more eyes on these changes.
> 
> Cool!
> 
> Would it help to download the db to a temporary file, and rename it on
> success?
> 

I looked at that approach quite some time ago.  The issue is things like
alpm_db_validate take a db pointer and construct paths using that.  It
could be worked around by creating a temporary sync directory and
setting that in the handle, but I thought this way was easier/cleaner.

Allan


More information about the pacman-dev mailing list