Fossil SCM

Fix the /doc webpage so that it does not call fossil_fatal() when it cannot find the requested document. It simply does a 404 routine. By not calling fossil_fatal(), it avoids unnecessary entries in the error log.

drh 2018-06-24 18:47 trunk
Commit 29cb8260c0d62ec60ff098bbe99336eb2d46a2d53e39bcc2b8540a1aa0167242
2 files changed +2 -3 -2
+2 -3
--- src/doc.c
+++ src/doc.c
@@ -664,12 +664,12 @@
664664
&& blob_read_from_file(&filebody, zFullpath, RepoFILE)>0 ){
665665
rid = 1; /* Fake RID just to get the loop to end */
666666
}
667667
fossil_free(zFullpath);
668668
}else{
669
- vid = name_to_typed_rid(zCheckin, "ci");
670
- rid = doc_load_content(vid, zName, &filebody);
669
+ vid = symbolic_name_to_rid(zCheckin, "ci");
670
+ rid = vid>0 ? doc_load_content(vid, zName, &filebody) : 0;
671671
}
672672
}
673673
g.zPath = mprintf("%s/%s", g.zPath, zPathSuffix);
674674
if( rid==0 ) goto doc_not_found;
675675
blob_to_utf8_no_bom(&filebody, 0);
@@ -764,11 +764,10 @@
764764
@ <p>Document %h(zOrigName) not found
765765
if( fossil_strcmp(zCheckin,"ckout")!=0 ){
766766
@ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
767767
}
768768
style_footer();
769
- db_end_transaction(0);
770769
return;
771770
}
772771
773772
/*
774773
** The default logo.
775774
--- src/doc.c
+++ src/doc.c
@@ -664,12 +664,12 @@
664 && blob_read_from_file(&filebody, zFullpath, RepoFILE)>0 ){
665 rid = 1; /* Fake RID just to get the loop to end */
666 }
667 fossil_free(zFullpath);
668 }else{
669 vid = name_to_typed_rid(zCheckin, "ci");
670 rid = doc_load_content(vid, zName, &filebody);
671 }
672 }
673 g.zPath = mprintf("%s/%s", g.zPath, zPathSuffix);
674 if( rid==0 ) goto doc_not_found;
675 blob_to_utf8_no_bom(&filebody, 0);
@@ -764,11 +764,10 @@
764 @ <p>Document %h(zOrigName) not found
765 if( fossil_strcmp(zCheckin,"ckout")!=0 ){
766 @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
767 }
768 style_footer();
769 db_end_transaction(0);
770 return;
771 }
772
773 /*
774 ** The default logo.
775
--- src/doc.c
+++ src/doc.c
@@ -664,12 +664,12 @@
664 && blob_read_from_file(&filebody, zFullpath, RepoFILE)>0 ){
665 rid = 1; /* Fake RID just to get the loop to end */
666 }
667 fossil_free(zFullpath);
668 }else{
669 vid = symbolic_name_to_rid(zCheckin, "ci");
670 rid = vid>0 ? doc_load_content(vid, zName, &filebody) : 0;
671 }
672 }
673 g.zPath = mprintf("%s/%s", g.zPath, zPathSuffix);
674 if( rid==0 ) goto doc_not_found;
675 blob_to_utf8_no_bom(&filebody, 0);
@@ -764,11 +764,10 @@
764 @ <p>Document %h(zOrigName) not found
765 if( fossil_strcmp(zCheckin,"ckout")!=0 ){
766 @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
767 }
768 style_footer();
 
769 return;
770 }
771
772 /*
773 ** The default logo.
774
-2
--- src/name.c
+++ src/name.c
@@ -423,14 +423,12 @@
423423
int rid;
424424
425425
if( zName==0 || zName[0]==0 ) return 0;
426426
rid = symbolic_name_to_rid(zName, zType);
427427
if( rid<0 ){
428
- cgi_set_status(404, "Not Found");
429428
fossil_fatal("ambiguous name: %s", zName);
430429
}else if( rid==0 ){
431
- cgi_set_status(404, "Not Found");
432430
fossil_fatal("not found: %s", zName);
433431
}
434432
return rid;
435433
}
436434
int name_to_rid(const char *zName){
437435
--- src/name.c
+++ src/name.c
@@ -423,14 +423,12 @@
423 int rid;
424
425 if( zName==0 || zName[0]==0 ) return 0;
426 rid = symbolic_name_to_rid(zName, zType);
427 if( rid<0 ){
428 cgi_set_status(404, "Not Found");
429 fossil_fatal("ambiguous name: %s", zName);
430 }else if( rid==0 ){
431 cgi_set_status(404, "Not Found");
432 fossil_fatal("not found: %s", zName);
433 }
434 return rid;
435 }
436 int name_to_rid(const char *zName){
437
--- src/name.c
+++ src/name.c
@@ -423,14 +423,12 @@
423 int rid;
424
425 if( zName==0 || zName[0]==0 ) return 0;
426 rid = symbolic_name_to_rid(zName, zType);
427 if( rid<0 ){
 
428 fossil_fatal("ambiguous name: %s", zName);
429 }else if( rid==0 ){
 
430 fossil_fatal("not found: %s", zName);
431 }
432 return rid;
433 }
434 int name_to_rid(const char *zName){
435

Keyboard Shortcuts

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