Fossil SCM
(cherry-pick): Correct /doc webpage in the case of a read-only database containing a vcache table lacking the desired vid
Commit
1fdcb20707c3edfa43f3151f324aea5d470204b198a48902b41b767aa3b6638c
Parent
746668d58b1878d…
1 file changed
+6
-5
+6
-5
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -464,19 +464,20 @@ | ||
| 464 | 464 | ** Look for a file named zName in the check-in with RID=vid. Load the content |
| 465 | 465 | ** of that file into pContent and return the RID for the file. Or return 0 |
| 466 | 466 | ** if the file is not found or could not be loaded. |
| 467 | 467 | */ |
| 468 | 468 | int doc_load_content(int vid, const char *zName, Blob *pContent){ |
| 469 | + int writable = db_is_writeable("repository"); | |
| 469 | 470 | int rid; /* The RID of the file being loaded */ |
| 470 | - if( !db_table_exists("repository","vcache") ){ | |
| 471 | + if( !db_table_exists("repository", "vcache") || !writable ){ | |
| 471 | 472 | db_multi_exec( |
| 472 | - "CREATE TABLE IF NOT EXISTS vcache(\n" | |
| 473 | + "CREATE %s TABLE IF NOT EXISTS vcache(\n" | |
| 473 | 474 | " vid INTEGER, -- check-in ID\n" |
| 474 | 475 | " fname TEXT, -- filename\n" |
| 475 | 476 | " rid INTEGER, -- artifact ID\n" |
| 476 | 477 | " PRIMARY KEY(vid,fname)\n" |
| 477 | - ") WITHOUT ROWID" | |
| 478 | + ") WITHOUT ROWID", writable ? "" : "TEMPORARY" | |
| 478 | 479 | ); |
| 479 | 480 | } |
| 480 | 481 | if( !db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){ |
| 481 | 482 | db_multi_exec( |
| 482 | 483 | "DELETE FROM vcache;\n" |
| @@ -496,17 +497,17 @@ | ||
| 496 | 497 | return rid; |
| 497 | 498 | } |
| 498 | 499 | |
| 499 | 500 | /* |
| 500 | 501 | ** Transfer content to the output. During the transfer, when text of |
| 501 | -** the followign form is seen: | |
| 502 | +** the following form is seen: | |
| 502 | 503 | ** |
| 503 | 504 | ** href="$ROOT/ |
| 504 | 505 | ** action="$ROOT/ |
| 505 | 506 | ** |
| 506 | 507 | ** 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. | |
| 508 | 509 | */ |
| 509 | 510 | static void convert_href_and_output(Blob *pIn){ |
| 510 | 511 | int i, base; |
| 511 | 512 | int n = blob_size(pIn); |
| 512 | 513 | char *z = blob_buffer(pIn); |
| 513 | 514 |
| --- 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 |