fix the restore logic when db file is damaged