Fossil SCM

(cherry-pick): Correct /doc webpage in the case of a read-only database containing a vcache table lacking the desired vid

jan.nijtmans 2017-09-21 09:56 UTC branch-2.3
Commit 1fdcb20707c3edfa43f3151f324aea5d470204b198a48902b41b767aa3b6638c
1 file changed +6 -5
+6 -5
--- src/doc.c
+++ src/doc.c
@@ -464,19 +464,20 @@
464464
** Look for a file named zName in the check-in with RID=vid. Load the content
465465
** of that file into pContent and return the RID for the file. Or return 0
466466
** if the file is not found or could not be loaded.
467467
*/
468468
int doc_load_content(int vid, const char *zName, Blob *pContent){
469
+ int writable = db_is_writeable("repository");
469470
int rid; /* The RID of the file being loaded */
470
- if( !db_table_exists("repository","vcache") ){
471
+ if( !db_table_exists("repository", "vcache") || !writable ){
471472
db_multi_exec(
472
- "CREATE TABLE IF NOT EXISTS vcache(\n"
473
+ "CREATE %s TABLE IF NOT EXISTS vcache(\n"
473474
" vid INTEGER, -- check-in ID\n"
474475
" fname TEXT, -- filename\n"
475476
" rid INTEGER, -- artifact ID\n"
476477
" PRIMARY KEY(vid,fname)\n"
477
- ") WITHOUT ROWID"
478
+ ") WITHOUT ROWID", writable ? "" : "TEMPORARY"
478479
);
479480
}
480481
if( !db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){
481482
db_multi_exec(
482483
"DELETE FROM vcache;\n"
@@ -496,17 +497,17 @@
496497
return rid;
497498
}
498499
499500
/*
500501
** Transfer content to the output. During the transfer, when text of
501
-** the followign form is seen:
502
+** the following form is seen:
502503
**
503504
** href="$ROOT/
504505
** action="$ROOT/
505506
**
506507
** Convert $ROOT to the root URI of the repository. Allow ' in place of "
507
-** and any case for href.
508
+** and any case for href or action.
508509
*/
509510
static void convert_href_and_output(Blob *pIn){
510511
int i, base;
511512
int n = blob_size(pIn);
512513
char *z = blob_buffer(pIn);
513514
--- src/doc.c
+++ src/doc.c
@@ -464,19 +464,20 @@
464 ** Look for a file named zName in the check-in with RID=vid. Load the content
465 ** of that file into pContent and return the RID for the file. Or return 0
466 ** if the file is not found or could not be loaded.
467 */
468 int doc_load_content(int vid, const char *zName, Blob *pContent){
 
469 int rid; /* The RID of the file being loaded */
470 if( !db_table_exists("repository","vcache") ){
471 db_multi_exec(
472 "CREATE TABLE IF NOT EXISTS vcache(\n"
473 " vid INTEGER, -- check-in ID\n"
474 " fname TEXT, -- filename\n"
475 " rid INTEGER, -- artifact ID\n"
476 " PRIMARY KEY(vid,fname)\n"
477 ") WITHOUT ROWID"
478 );
479 }
480 if( !db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){
481 db_multi_exec(
482 "DELETE FROM vcache;\n"
@@ -496,17 +497,17 @@
496 return rid;
497 }
498
499 /*
500 ** Transfer content to the output. During the transfer, when text of
501 ** the followign form is seen:
502 **
503 ** href="$ROOT/
504 ** action="$ROOT/
505 **
506 ** Convert $ROOT to the root URI of the repository. Allow ' in place of "
507 ** and any case for href.
508 */
509 static void convert_href_and_output(Blob *pIn){
510 int i, base;
511 int n = blob_size(pIn);
512 char *z = blob_buffer(pIn);
513
--- src/doc.c
+++ src/doc.c
@@ -464,19 +464,20 @@
464 ** Look for a file named zName in the check-in with RID=vid. Load the content
465 ** of that file into pContent and return the RID for the file. Or return 0
466 ** if the file is not found or could not be loaded.
467 */
468 int doc_load_content(int vid, const char *zName, Blob *pContent){
469 int writable = db_is_writeable("repository");
470 int rid; /* The RID of the file being loaded */
471 if( !db_table_exists("repository", "vcache") || !writable ){
472 db_multi_exec(
473 "CREATE %s TABLE IF NOT EXISTS vcache(\n"
474 " vid INTEGER, -- check-in ID\n"
475 " fname TEXT, -- filename\n"
476 " rid INTEGER, -- artifact ID\n"
477 " PRIMARY KEY(vid,fname)\n"
478 ") WITHOUT ROWID", writable ? "" : "TEMPORARY"
479 );
480 }
481 if( !db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){
482 db_multi_exec(
483 "DELETE FROM vcache;\n"
@@ -496,17 +497,17 @@
497 return rid;
498 }
499
500 /*
501 ** Transfer content to the output. During the transfer, when text of
502 ** the following form is seen:
503 **
504 ** href="$ROOT/
505 ** action="$ROOT/
506 **
507 ** Convert $ROOT to the root URI of the repository. Allow ' in place of "
508 ** and any case for href or action.
509 */
510 static void convert_href_and_output(Blob *pIn){
511 int i, base;
512 int n = blob_size(pIn);
513 char *z = blob_buffer(pIn);
514

Keyboard Shortcuts

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