Fossil SCM
Fixed a logic bug which caused /json/wiki/create to not be able to create a new page.
Commit
64c2ec012c7889c6ead9a73be9ef84bc623aa821
Parent
24d830ca8aa17d7…
1 file changed
+4
-4
+4
-4
| --- src/json_wiki.c | ||
| +++ src/json_wiki.c | ||
| @@ -262,15 +262,15 @@ | ||
| 262 | 262 | ** here if it doesn't already exist. With that, save/create would |
| 263 | 263 | ** become one operation. That said, i expect there are people who |
| 264 | 264 | ** would categorize such behaviour as "being too clever" or "doing too |
| 265 | 265 | ** much automatically" (and i would likely agree with them). |
| 266 | 266 | ** |
| 267 | -** If allowCreateIfExists is true then this function will allow a new | |
| 267 | +** If allowCreateIfNotExists is true then this function will allow a new | |
| 268 | 268 | ** page to be created even if createMode is false. |
| 269 | 269 | */ |
| 270 | 270 | static cson_value * json_wiki_create_or_save(char createMode, |
| 271 | - char allowCreateIfExists){ | |
| 271 | + char allowCreateIfNotExists){ | |
| 272 | 272 | Blob content = empty_blob; /* wiki page content */ |
| 273 | 273 | cson_value * nameV; /* wiki page name */ |
| 274 | 274 | char const * zPageName; /* cstr form of page name */ |
| 275 | 275 | cson_value * contentV; /* passed-in content */ |
| 276 | 276 | cson_value * emptyContent = NULL; /* placeholder for empty content. */ |
| @@ -304,20 +304,20 @@ | ||
| 304 | 304 | json_set_err(FSL_JSON_E_RESOURCE_ALREADY_EXISTS, |
| 305 | 305 | "Wiki page '%s' already exists.", |
| 306 | 306 | zPageName); |
| 307 | 307 | goto error; |
| 308 | 308 | } |
| 309 | - }else if(!allowCreateIfExists){ | |
| 309 | + }else if(!createMode && !allowCreateIfNotExists){ | |
| 310 | 310 | json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND, |
| 311 | 311 | "Wiki page '%s' not found.", |
| 312 | 312 | zPageName); |
| 313 | 313 | goto error; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | contentV = json_req_payload_get("content"); |
| 317 | 317 | if( !contentV ){ |
| 318 | - if( createMode || (!rid && allowCreateIfExists) ){ | |
| 318 | + if( createMode || (!rid && allowCreateIfNotExists) ){ | |
| 319 | 319 | contentV = emptyContent = cson_value_new_string("",0); |
| 320 | 320 | }else{ |
| 321 | 321 | json_set_err(FSL_JSON_E_MISSING_ARGS, |
| 322 | 322 | "'content' parameter is missing."); |
| 323 | 323 | goto error; |
| 324 | 324 |
| --- src/json_wiki.c | |
| +++ src/json_wiki.c | |
| @@ -262,15 +262,15 @@ | |
| 262 | ** here if it doesn't already exist. With that, save/create would |
| 263 | ** become one operation. That said, i expect there are people who |
| 264 | ** would categorize such behaviour as "being too clever" or "doing too |
| 265 | ** much automatically" (and i would likely agree with them). |
| 266 | ** |
| 267 | ** If allowCreateIfExists is true then this function will allow a new |
| 268 | ** page to be created even if createMode is false. |
| 269 | */ |
| 270 | static cson_value * json_wiki_create_or_save(char createMode, |
| 271 | char allowCreateIfExists){ |
| 272 | Blob content = empty_blob; /* wiki page content */ |
| 273 | cson_value * nameV; /* wiki page name */ |
| 274 | char const * zPageName; /* cstr form of page name */ |
| 275 | cson_value * contentV; /* passed-in content */ |
| 276 | cson_value * emptyContent = NULL; /* placeholder for empty content. */ |
| @@ -304,20 +304,20 @@ | |
| 304 | json_set_err(FSL_JSON_E_RESOURCE_ALREADY_EXISTS, |
| 305 | "Wiki page '%s' already exists.", |
| 306 | zPageName); |
| 307 | goto error; |
| 308 | } |
| 309 | }else if(!allowCreateIfExists){ |
| 310 | json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND, |
| 311 | "Wiki page '%s' not found.", |
| 312 | zPageName); |
| 313 | goto error; |
| 314 | } |
| 315 | |
| 316 | contentV = json_req_payload_get("content"); |
| 317 | if( !contentV ){ |
| 318 | if( createMode || (!rid && allowCreateIfExists) ){ |
| 319 | contentV = emptyContent = cson_value_new_string("",0); |
| 320 | }else{ |
| 321 | json_set_err(FSL_JSON_E_MISSING_ARGS, |
| 322 | "'content' parameter is missing."); |
| 323 | goto error; |
| 324 |
| --- src/json_wiki.c | |
| +++ src/json_wiki.c | |
| @@ -262,15 +262,15 @@ | |
| 262 | ** here if it doesn't already exist. With that, save/create would |
| 263 | ** become one operation. That said, i expect there are people who |
| 264 | ** would categorize such behaviour as "being too clever" or "doing too |
| 265 | ** much automatically" (and i would likely agree with them). |
| 266 | ** |
| 267 | ** If allowCreateIfNotExists is true then this function will allow a new |
| 268 | ** page to be created even if createMode is false. |
| 269 | */ |
| 270 | static cson_value * json_wiki_create_or_save(char createMode, |
| 271 | char allowCreateIfNotExists){ |
| 272 | Blob content = empty_blob; /* wiki page content */ |
| 273 | cson_value * nameV; /* wiki page name */ |
| 274 | char const * zPageName; /* cstr form of page name */ |
| 275 | cson_value * contentV; /* passed-in content */ |
| 276 | cson_value * emptyContent = NULL; /* placeholder for empty content. */ |
| @@ -304,20 +304,20 @@ | |
| 304 | json_set_err(FSL_JSON_E_RESOURCE_ALREADY_EXISTS, |
| 305 | "Wiki page '%s' already exists.", |
| 306 | zPageName); |
| 307 | goto error; |
| 308 | } |
| 309 | }else if(!createMode && !allowCreateIfNotExists){ |
| 310 | json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND, |
| 311 | "Wiki page '%s' not found.", |
| 312 | zPageName); |
| 313 | goto error; |
| 314 | } |
| 315 | |
| 316 | contentV = json_req_payload_get("content"); |
| 317 | if( !contentV ){ |
| 318 | if( createMode || (!rid && allowCreateIfNotExists) ){ |
| 319 | contentV = emptyContent = cson_value_new_string("",0); |
| 320 | }else{ |
| 321 | json_set_err(FSL_JSON_E_MISSING_ARGS, |
| 322 | "'content' parameter is missing."); |
| 323 | goto error; |
| 324 |