Fossil SCM
Correct /doc webpage in the case of a read-only database containing a vcache table lacking the desired vid
Commit
b20f6cbaf4aabb5e603ebbf74803e53e66916ef65eb4c4a26977adeb193e6c47
Parent
aad384d5d17fd21…
1 file changed
+3
-2
+3
-2
| --- 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 | 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", db_is_writeable("repository") ? "" : "TEMPORARY" | |
| 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" |
| 483 | 484 |
| --- 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 %s 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", db_is_writeable("repository") ? "" : "TEMPORARY" |
| 478 | ); |
| 479 | } |
| 480 | if( !db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){ |
| 481 | db_multi_exec( |
| 482 | "DELETE FROM vcache;\n" |
| 483 |
| --- 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" |
| 484 |