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.

stephan 2011-09-29 15:23 UTC json
Commit 071de8f1bd5b84540b78c6ac0b0f9e7073c86a79
1 file changed +23
+23
--- src/json.c
+++ src/json.c
@@ -1673,10 +1673,32 @@
16731673
}
16741674
}
16751675
return payV;
16761676
}
16771677
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
+}
16781700
16791701
/*
16801702
** Impl of /json/user/list. Requires admin rights.
16811703
*/
16821704
static cson_value * json_user_list(){
@@ -1761,10 +1783,11 @@
17611783
{"cap", json_page_cap, 0},
17621784
{"dir", json_page_nyi, 0},
17631785
{"HAI",json_page_version,0},
17641786
{"login",json_page_login,1},
17651787
{"logout",json_page_logout,1},
1788
+{"rebuild",json_page_rebuild,0},
17661789
{"stat",json_page_stat,0},
17671790
{"tag", json_page_nyi,0},
17681791
{"ticket", json_page_nyi,0},
17691792
{"timeline", json_page_timeline,0},
17701793
{"user",json_page_user,0},
17711794
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button