Fossil SCM

Add some comments explaining the reason behind a particular attachment-handling case. Remove the new (in this branch) CFTYPE_TECHNOTE alias for CFTYPE_EVENT.

stephan 2026-05-23 17:34 UTC forum-attachments
Commit 782b8b8e81abc83303f09a8550d16818a7151388c5ca45e6b2925217b6379076
2 files changed +8 -8 +5 -2
+8 -8
--- src/attach.c
+++ src/attach.c
@@ -22,11 +22,11 @@
2222
#include <assert.h>
2323
2424
/*
2525
** Given a presumedly legal attachment target name, this guesses the
2626
** target type and returns one of CFTYPE_FORUM, CFTYPE_WIKI,
27
-** CFTYPE_TICKET, or CFTYPE_TECHNOTE. Returns 0 if it cannot
27
+** CFTYPE_TICKET, or CFTYPE_EVENT. Returns 0 if it cannot
2828
** distinguish the target type.
2929
**
3030
** In the case of CFTYPE_FORUM, it is up to the caller to ensure that,
3131
** if needed, they resolve zTarget using forumpost_head_rid2() so that
3232
** they get the RID of the earliest version of the post, as that is
@@ -44,11 +44,11 @@
4444
"SELECT CASE "
4545
"WHEN 'tkt-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
4646
"WHEN 'event-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
4747
"WHEN 'wiki-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
4848
"ELSE 0 END",
49
- CFTYPE_TICKET, CFTYPE_TECHNOTE, CFTYPE_WIKI
49
+ CFTYPE_TICKET, CFTYPE_EVENT, CFTYPE_WIKI
5050
);
5151
}
5252
db_bind_text(&q, ":tgt", zTarget);
5353
if( SQLITE_ROW==db_step(&q) ){
5454
rc = db_column_int(&q, 0);
@@ -150,11 +150,11 @@
150150
}
151151
switch( type ){
152152
case CFTYPE_TICKET:
153153
zUrlTail = mprintf("tkt=%s&file=%t", zTarget, zFilename);
154154
break;
155
- case CFTYPE_TECHNOTE:
155
+ case CFTYPE_EVENT:
156156
zUrlTail = mprintf("technote=%s&file=%t", zTarget, zFilename);
157157
break;
158158
case CFTYPE_FORUM:
159159
zUrlTail = mprintf("forumpost=%t&file=%t", zTarget, zFilename);
160160
break;
@@ -180,11 +180,11 @@
180180
switch( type ){
181181
case CFTYPE_TICKET:
182182
@ %s(zSrc) ticket <a href="%R/tktview?name=%s(zTarget)">
183183
@ %S(zTarget)</a>
184184
break;
185
- case CFTYPE_TECHNOTE:
185
+ case CFTYPE_EVENT:
186186
@ %s(zSrc) tech note <a href="%R/technote/%s(zTarget)">
187187
@ %S(zTarget)</a>
188188
break;
189189
case CFTYPE_WIKI:
190190
@ %s(zSrc) wiki page <a href="%R/wiki?name=%t(zTarget)">
@@ -816,15 +816,15 @@
816816
@ %s(zHeader)
817817
@ <ul>
818818
}
819819
cnt++;
820820
switch( iAType ){
821
- case CFTYPE_TICKET: zTypeArg = "tkt"; break;
822
- case CFTYPE_FORUM: zTypeArg = "forumpost"; break;
823
- case CFTYPE_TECHNOTE: zTypeArg = "technote"; break;
821
+ case CFTYPE_TICKET: zTypeArg = "tkt"; break;
822
+ case CFTYPE_FORUM: zTypeArg = "forumpost"; break;
823
+ case CFTYPE_EVENT: zTypeArg = "technote"; break;
824824
case CFTYPE_WIKI:
825
- default: zTypeArg = "page"; break;
825
+ default: zTypeArg = "page"; break;
826826
}
827827
@ <li>
828828
@ <a href="%R/artifact/%!S(zSrc)"%s(zLinkTgt)>%h(zFile)</a>
829829
if( flags & ATTACHLIST_SIZE ){
830830
const int sz = db_int(0,"SELECT size FROM blob WHERE uuid=%Q", zSrc);
831831
--- src/attach.c
+++ src/attach.c
@@ -22,11 +22,11 @@
22 #include <assert.h>
23
24 /*
25 ** Given a presumedly legal attachment target name, this guesses the
26 ** target type and returns one of CFTYPE_FORUM, CFTYPE_WIKI,
27 ** CFTYPE_TICKET, or CFTYPE_TECHNOTE. Returns 0 if it cannot
28 ** distinguish the target type.
29 **
30 ** In the case of CFTYPE_FORUM, it is up to the caller to ensure that,
31 ** if needed, they resolve zTarget using forumpost_head_rid2() so that
32 ** they get the RID of the earliest version of the post, as that is
@@ -44,11 +44,11 @@
44 "SELECT CASE "
45 "WHEN 'tkt-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
46 "WHEN 'event-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
47 "WHEN 'wiki-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
48 "ELSE 0 END",
49 CFTYPE_TICKET, CFTYPE_TECHNOTE, CFTYPE_WIKI
50 );
51 }
52 db_bind_text(&q, ":tgt", zTarget);
53 if( SQLITE_ROW==db_step(&q) ){
54 rc = db_column_int(&q, 0);
@@ -150,11 +150,11 @@
150 }
151 switch( type ){
152 case CFTYPE_TICKET:
153 zUrlTail = mprintf("tkt=%s&file=%t", zTarget, zFilename);
154 break;
155 case CFTYPE_TECHNOTE:
156 zUrlTail = mprintf("technote=%s&file=%t", zTarget, zFilename);
157 break;
158 case CFTYPE_FORUM:
159 zUrlTail = mprintf("forumpost=%t&file=%t", zTarget, zFilename);
160 break;
@@ -180,11 +180,11 @@
180 switch( type ){
181 case CFTYPE_TICKET:
182 @ %s(zSrc) ticket <a href="%R/tktview?name=%s(zTarget)">
183 @ %S(zTarget)</a>
184 break;
185 case CFTYPE_TECHNOTE:
186 @ %s(zSrc) tech note <a href="%R/technote/%s(zTarget)">
187 @ %S(zTarget)</a>
188 break;
189 case CFTYPE_WIKI:
190 @ %s(zSrc) wiki page <a href="%R/wiki?name=%t(zTarget)">
@@ -816,15 +816,15 @@
816 @ %s(zHeader)
817 @ <ul>
818 }
819 cnt++;
820 switch( iAType ){
821 case CFTYPE_TICKET: zTypeArg = "tkt"; break;
822 case CFTYPE_FORUM: zTypeArg = "forumpost"; break;
823 case CFTYPE_TECHNOTE: zTypeArg = "technote"; break;
824 case CFTYPE_WIKI:
825 default: zTypeArg = "page"; break;
826 }
827 @ <li>
828 @ <a href="%R/artifact/%!S(zSrc)"%s(zLinkTgt)>%h(zFile)</a>
829 if( flags & ATTACHLIST_SIZE ){
830 const int sz = db_int(0,"SELECT size FROM blob WHERE uuid=%Q", zSrc);
831
--- src/attach.c
+++ src/attach.c
@@ -22,11 +22,11 @@
22 #include <assert.h>
23
24 /*
25 ** Given a presumedly legal attachment target name, this guesses the
26 ** target type and returns one of CFTYPE_FORUM, CFTYPE_WIKI,
27 ** CFTYPE_TICKET, or CFTYPE_EVENT. Returns 0 if it cannot
28 ** distinguish the target type.
29 **
30 ** In the case of CFTYPE_FORUM, it is up to the caller to ensure that,
31 ** if needed, they resolve zTarget using forumpost_head_rid2() so that
32 ** they get the RID of the earliest version of the post, as that is
@@ -44,11 +44,11 @@
44 "SELECT CASE "
45 "WHEN 'tkt-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
46 "WHEN 'event-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
47 "WHEN 'wiki-'||:tgt IN (SELECT tagname FROM tag) THEN %d "
48 "ELSE 0 END",
49 CFTYPE_TICKET, CFTYPE_EVENT, CFTYPE_WIKI
50 );
51 }
52 db_bind_text(&q, ":tgt", zTarget);
53 if( SQLITE_ROW==db_step(&q) ){
54 rc = db_column_int(&q, 0);
@@ -150,11 +150,11 @@
150 }
151 switch( type ){
152 case CFTYPE_TICKET:
153 zUrlTail = mprintf("tkt=%s&file=%t", zTarget, zFilename);
154 break;
155 case CFTYPE_EVENT:
156 zUrlTail = mprintf("technote=%s&file=%t", zTarget, zFilename);
157 break;
158 case CFTYPE_FORUM:
159 zUrlTail = mprintf("forumpost=%t&file=%t", zTarget, zFilename);
160 break;
@@ -180,11 +180,11 @@
180 switch( type ){
181 case CFTYPE_TICKET:
182 @ %s(zSrc) ticket <a href="%R/tktview?name=%s(zTarget)">
183 @ %S(zTarget)</a>
184 break;
185 case CFTYPE_EVENT:
186 @ %s(zSrc) tech note <a href="%R/technote/%s(zTarget)">
187 @ %S(zTarget)</a>
188 break;
189 case CFTYPE_WIKI:
190 @ %s(zSrc) wiki page <a href="%R/wiki?name=%t(zTarget)">
@@ -816,15 +816,15 @@
816 @ %s(zHeader)
817 @ <ul>
818 }
819 cnt++;
820 switch( iAType ){
821 case CFTYPE_TICKET: zTypeArg = "tkt"; break;
822 case CFTYPE_FORUM: zTypeArg = "forumpost"; break;
823 case CFTYPE_EVENT: zTypeArg = "technote"; break;
824 case CFTYPE_WIKI:
825 default: zTypeArg = "page"; break;
826 }
827 @ <li>
828 @ <a href="%R/artifact/%!S(zSrc)"%s(zLinkTgt)>%h(zFile)</a>
829 if( flags & ATTACHLIST_SIZE ){
830 const int sz = db_int(0,"SELECT size FROM blob WHERE uuid=%Q", zSrc);
831
+5 -2
--- src/manifest.c
+++ src/manifest.c
@@ -33,12 +33,11 @@
3333
#define CFTYPE_CLUSTER 2
3434
#define CFTYPE_CONTROL 3
3535
#define CFTYPE_WIKI 4
3636
#define CFTYPE_TICKET 5
3737
#define CFTYPE_ATTACHMENT 6
38
-#define CFTYPE_EVENT 7 /* older name for CFTYPE_TECHNOTE */
39
-#define CFTYPE_TECHNOTE 7
38
+#define CFTYPE_EVENT 7
4039
#define CFTYPE_FORUM 8
4140
4241
/*
4342
** File permissions used by Fossil internally.
4443
*/
@@ -2649,10 +2648,14 @@
26492648
p->zAttachTarget, p->zAttachName,
26502649
p->zAttachTarget, p->zAttachName
26512650
);
26522651
switch( attachment_target_type(p->zAttachTarget) ){
26532652
case 0:
2653
+ /* It is possible that p->zAttachTarget is not yet in this
2654
+ ** copy of the repository. If we cannot identify it yet,
2655
+ ** generate a generic /artifact link to it instead of a
2656
+ ** type-specific link or an error message. */
26542657
attachToType = 'a';
26552658
if( isAdd ){
26562659
zComment = mprintf(
26572660
"Add attachment [/artifact/%!S|%h] to [/artifact/%!S|%h]",
26582661
p->zAttachSrc, p->zAttachName,
26592662
--- src/manifest.c
+++ src/manifest.c
@@ -33,12 +33,11 @@
33 #define CFTYPE_CLUSTER 2
34 #define CFTYPE_CONTROL 3
35 #define CFTYPE_WIKI 4
36 #define CFTYPE_TICKET 5
37 #define CFTYPE_ATTACHMENT 6
38 #define CFTYPE_EVENT 7 /* older name for CFTYPE_TECHNOTE */
39 #define CFTYPE_TECHNOTE 7
40 #define CFTYPE_FORUM 8
41
42 /*
43 ** File permissions used by Fossil internally.
44 */
@@ -2649,10 +2648,14 @@
2649 p->zAttachTarget, p->zAttachName,
2650 p->zAttachTarget, p->zAttachName
2651 );
2652 switch( attachment_target_type(p->zAttachTarget) ){
2653 case 0:
 
 
 
 
2654 attachToType = 'a';
2655 if( isAdd ){
2656 zComment = mprintf(
2657 "Add attachment [/artifact/%!S|%h] to [/artifact/%!S|%h]",
2658 p->zAttachSrc, p->zAttachName,
2659
--- src/manifest.c
+++ src/manifest.c
@@ -33,12 +33,11 @@
33 #define CFTYPE_CLUSTER 2
34 #define CFTYPE_CONTROL 3
35 #define CFTYPE_WIKI 4
36 #define CFTYPE_TICKET 5
37 #define CFTYPE_ATTACHMENT 6
38 #define CFTYPE_EVENT 7
 
39 #define CFTYPE_FORUM 8
40
41 /*
42 ** File permissions used by Fossil internally.
43 */
@@ -2649,10 +2648,14 @@
2648 p->zAttachTarget, p->zAttachName,
2649 p->zAttachTarget, p->zAttachName
2650 );
2651 switch( attachment_target_type(p->zAttachTarget) ){
2652 case 0:
2653 /* It is possible that p->zAttachTarget is not yet in this
2654 ** copy of the repository. If we cannot identify it yet,
2655 ** generate a generic /artifact link to it instead of a
2656 ** type-specific link or an error message. */
2657 attachToType = 'a';
2658 if( isAdd ){
2659 zComment = mprintf(
2660 "Add attachment [/artifact/%!S|%h] to [/artifact/%!S|%h]",
2661 p->zAttachSrc, p->zAttachName,
2662

Keyboard Shortcuts

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