Fossil SCM
Added /json/rebuild. Is likely to fail w/ an AJAX timeout for large repos, which will probably cause the rebuild to roll back on the next open :/. Takes 21sec on my 32-bit netbook to rebuild the fossil repo.
Commit
071de8f1bd5b84540b78c6ac0b0f9e7073c86a79
Parent
5ddfe3d6630e137…
1 file changed
+23
+23
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -1673,10 +1673,32 @@ | ||
| 1673 | 1673 | } |
| 1674 | 1674 | } |
| 1675 | 1675 | return payV; |
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | +/* | |
| 1679 | +** Impl of /json/rebuild. Requires admin previleges. | |
| 1680 | +*/ | |
| 1681 | +static cson_value * json_page_rebuild(){ | |
| 1682 | +if( !g.perm.Admin ){ | |
| 1683 | + g.json.resultCode = FSL_JSON_E_DENIED; | |
| 1684 | + return NULL; | |
| 1685 | + }else{ | |
| 1686 | + /* Reminder: the db_xxx() ops "should" fail via | |
| 1687 | + the fossil core error handlers, which will cause | |
| 1688 | + a JSON error and exit(). i.e. we don't handle | |
| 1689 | + the errors here. TODO: confirm that all these | |
| 1690 | + db routine fail gracefully in JSON mode. | |
| 1691 | + */ | |
| 1692 | + db_close(1); | |
| 1693 | + db_open_repository(g.zRepositoryName); | |
| 1694 | + db_begin_transaction(); | |
| 1695 | + rebuild_db(0, 0, 0); | |
| 1696 | + db_end_transaction(0); | |
| 1697 | + return NULL; | |
| 1698 | + } | |
| 1699 | +} | |
| 1678 | 1700 | |
| 1679 | 1701 | /* |
| 1680 | 1702 | ** Impl of /json/user/list. Requires admin rights. |
| 1681 | 1703 | */ |
| 1682 | 1704 | static cson_value * json_user_list(){ |
| @@ -1761,10 +1783,11 @@ | ||
| 1761 | 1783 | {"cap", json_page_cap, 0}, |
| 1762 | 1784 | {"dir", json_page_nyi, 0}, |
| 1763 | 1785 | {"HAI",json_page_version,0}, |
| 1764 | 1786 | {"login",json_page_login,1}, |
| 1765 | 1787 | {"logout",json_page_logout,1}, |
| 1788 | +{"rebuild",json_page_rebuild,0}, | |
| 1766 | 1789 | {"stat",json_page_stat,0}, |
| 1767 | 1790 | {"tag", json_page_nyi,0}, |
| 1768 | 1791 | {"ticket", json_page_nyi,0}, |
| 1769 | 1792 | {"timeline", json_page_timeline,0}, |
| 1770 | 1793 | {"user",json_page_user,0}, |
| 1771 | 1794 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1673,10 +1673,32 @@ | |
| 1673 | } |
| 1674 | } |
| 1675 | return payV; |
| 1676 | } |
| 1677 | |
| 1678 | |
| 1679 | /* |
| 1680 | ** Impl of /json/user/list. Requires admin rights. |
| 1681 | */ |
| 1682 | static cson_value * json_user_list(){ |
| @@ -1761,10 +1783,11 @@ | |
| 1761 | {"cap", json_page_cap, 0}, |
| 1762 | {"dir", json_page_nyi, 0}, |
| 1763 | {"HAI",json_page_version,0}, |
| 1764 | {"login",json_page_login,1}, |
| 1765 | {"logout",json_page_logout,1}, |
| 1766 | {"stat",json_page_stat,0}, |
| 1767 | {"tag", json_page_nyi,0}, |
| 1768 | {"ticket", json_page_nyi,0}, |
| 1769 | {"timeline", json_page_timeline,0}, |
| 1770 | {"user",json_page_user,0}, |
| 1771 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1673,10 +1673,32 @@ | |
| 1673 | } |
| 1674 | } |
| 1675 | return payV; |
| 1676 | } |
| 1677 | |
| 1678 | /* |
| 1679 | ** Impl of /json/rebuild. Requires admin previleges. |
| 1680 | */ |
| 1681 | static cson_value * json_page_rebuild(){ |
| 1682 | if( !g.perm.Admin ){ |
| 1683 | g.json.resultCode = FSL_JSON_E_DENIED; |
| 1684 | return NULL; |
| 1685 | }else{ |
| 1686 | /* Reminder: the db_xxx() ops "should" fail via |
| 1687 | the fossil core error handlers, which will cause |
| 1688 | a JSON error and exit(). i.e. we don't handle |
| 1689 | the errors here. TODO: confirm that all these |
| 1690 | db routine fail gracefully in JSON mode. |
| 1691 | */ |
| 1692 | db_close(1); |
| 1693 | db_open_repository(g.zRepositoryName); |
| 1694 | db_begin_transaction(); |
| 1695 | rebuild_db(0, 0, 0); |
| 1696 | db_end_transaction(0); |
| 1697 | return NULL; |
| 1698 | } |
| 1699 | } |
| 1700 | |
| 1701 | /* |
| 1702 | ** Impl of /json/user/list. Requires admin rights. |
| 1703 | */ |
| 1704 | static cson_value * json_user_list(){ |
| @@ -1761,10 +1783,11 @@ | |
| 1783 | {"cap", json_page_cap, 0}, |
| 1784 | {"dir", json_page_nyi, 0}, |
| 1785 | {"HAI",json_page_version,0}, |
| 1786 | {"login",json_page_login,1}, |
| 1787 | {"logout",json_page_logout,1}, |
| 1788 | {"rebuild",json_page_rebuild,0}, |
| 1789 | {"stat",json_page_stat,0}, |
| 1790 | {"tag", json_page_nyi,0}, |
| 1791 | {"ticket", json_page_nyi,0}, |
| 1792 | {"timeline", json_page_timeline,0}, |
| 1793 | {"user",json_page_user,0}, |
| 1794 |