Make update_repository() as atomic as possible