AmendHub

Download (as of this amendment):

jcs

/

amend

/

amendments

/

195

repo: If bile_open fails due to bad map, try to recover


jcs made amendment 195 18 days ago
--- repo.c Sun Oct 4 11:08:58 2026 +++ repo.c Sun Oct 4 11:46:43 2026 @@ -59,10 +59,20 @@ repo_open(AppFile *file) } bile = bile_open(reply.fName, reply.vRefNum); + if (bile == NULL && bile_error(NULL) == BILE_ERR_BAD_MAP) { + if (ask("Damaged index found, attempt to use the previous " + "index?")) + bile = bile_open_recover_map(reply.fName, reply.vRefNum); + else + return NULL; + } if (bile == NULL) { if (bile_error(NULL) == BILE_ERR_NEED_UPGRADE_1) warn("File %s is a version 1 repo and must be upgraded", PtoCstr(reply.fName)); + else if (bile_error(NULL) == BILE_ERR_BAD_MAP) + warn("Opening repo %s failed: index is damaged and previous " + "index is unavailable."); else warn("Opening repo %s failed: %d", PtoCstr(reply.fName), bile_error(NULL));