Fossil SCM

Correct /doc webpage in the case of a read-only database containing a vcache table lacking the desired vid

andygoth 2017-09-21 00:56 trunk
Commit b20f6cbaf4aabb5e603ebbf74803e53e66916ef65eb4c4a26977adeb193e6c47
1 file changed +3 -2
+3 -2
--- 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(
472473
"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", db_is_writeable("repository") ? "" : "TEMPORARY"
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"
483484
--- 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

Keyboard Shortcuts

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