Fossil SCM

fixed /json/wiki/get to fail with a resource-not-found error if given the name of an unknown page.

stephan 2012-02-16 20:12 trunk
Commit ac8c1ad4bbbf31d87b3d8dfe2035e600993d20a6
1 file changed +3 -1
+3 -1
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -59,11 +59,11 @@
5959
** parsing is performed, if it is 0 then the content is not returned
6060
** in the response. If contentFormat is 0 then the contentSize reflects
6161
** the number of bytes, not characters, stored in the page.
6262
**
6363
** The returned value, if not NULL, is-a JSON Object owned by the
64
-** caller.
64
+** caller. If it returns NULL then it may set g.json's error state.
6565
*/
6666
cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){
6767
int rid;
6868
Manifest *pWiki = 0;
6969
char const * zBody = NULL;
@@ -77,10 +77,12 @@
7777
" ORDER BY x.mtime DESC LIMIT 1",
7878
zPageName
7979
);
8080
if( (SQLITE_ROW != db_step(&q)) ){
8181
db_finalize(&q);
82
+ json_set_err( FSL_JSON_E_RESOURCE_NOT_FOUND, "Wiki page not found: %s",
83
+ zPageName );
8284
return NULL;
8385
}
8486
rid = db_column_int(&q,0);
8587
zUuid = db_column_malloc(&q,1);
8688
db_finalize(&q);
8789
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -59,11 +59,11 @@
59 ** parsing is performed, if it is 0 then the content is not returned
60 ** in the response. If contentFormat is 0 then the contentSize reflects
61 ** the number of bytes, not characters, stored in the page.
62 **
63 ** The returned value, if not NULL, is-a JSON Object owned by the
64 ** caller.
65 */
66 cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){
67 int rid;
68 Manifest *pWiki = 0;
69 char const * zBody = NULL;
@@ -77,10 +77,12 @@
77 " ORDER BY x.mtime DESC LIMIT 1",
78 zPageName
79 );
80 if( (SQLITE_ROW != db_step(&q)) ){
81 db_finalize(&q);
 
 
82 return NULL;
83 }
84 rid = db_column_int(&q,0);
85 zUuid = db_column_malloc(&q,1);
86 db_finalize(&q);
87
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -59,11 +59,11 @@
59 ** parsing is performed, if it is 0 then the content is not returned
60 ** in the response. If contentFormat is 0 then the contentSize reflects
61 ** the number of bytes, not characters, stored in the page.
62 **
63 ** The returned value, if not NULL, is-a JSON Object owned by the
64 ** caller. If it returns NULL then it may set g.json's error state.
65 */
66 cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){
67 int rid;
68 Manifest *pWiki = 0;
69 char const * zBody = NULL;
@@ -77,10 +77,12 @@
77 " ORDER BY x.mtime DESC LIMIT 1",
78 zPageName
79 );
80 if( (SQLITE_ROW != db_step(&q)) ){
81 db_finalize(&q);
82 json_set_err( FSL_JSON_E_RESOURCE_NOT_FOUND, "Wiki page not found: %s",
83 zPageName );
84 return NULL;
85 }
86 rid = db_column_int(&q,0);
87 zUuid = db_column_malloc(&q,1);
88 db_finalize(&q);
89

Keyboard Shortcuts

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