Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| SHA1 Hash: | 615a52f0ba072ae9a1116b0a8d92e621687d3ce3 |
|---|---|
| Date: | 2010-03-16 16:52:37 |
| User: | drh |
| Comment: | Change the format of the A-card for attachments again. Add the ATTACHMENT table to the repository. Insert attachment information into the ATTACHMENT table when processing attachment artifacts. |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
Changes to src/manifest.c
164 goto manifest_syntax_error; 164 goto manifest_syntax_error;
165 } 165 }
166 cPrevType = z[0]; 166 cPrevType = z[0];
167 seenHeader = 1; 167 seenHeader = 1;
168 if( blob_token(&line, &token)!=1 ) goto manifest_syntax_error; 168 if( blob_token(&line, &token)!=1 ) goto manifest_syntax_error;
169 switch( z[0] ){ 169 switch( z[0] ){
170 /* 170 /*
171 ** A (+|-)<filename> target source | 171 ** A <filename> <target> ?<source>?
172 ** 172 **
173 ** Identifies an attachment to either a wiki page or a ticket. 173 ** Identifies an attachment to either a wiki page or a ticket.
174 ** <uuid> is the artifact that is the attachment. | 174 ** <source> is the artifact that is the attachment. <source>
> 175 ** is omitted to delete an attachment. <target> is the name of
> 176 ** a wiki page or ticket to which that attachment is connected.
175 */ 177 */
176 case 'A': { 178 case 'A': {
177 char *zName, *zTarget, *zSrc; 179 char *zName, *zTarget, *zSrc;
178 md5sum_step_text(blob_buffer(&line), blob_size(&line)); 180 md5sum_step_text(blob_buffer(&line), blob_size(&line));
179 if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error; 181 if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
180 if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error; 182 if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
181 if( blob_token(&line, &a3)==0 ) goto manifest_syntax_error; <
182 if( p->zAttachName!=0 ) goto manifest_syntax_error; 183 if( p->zAttachName!=0 ) goto manifest_syntax_error;
183 zName = blob_terminate(&a1); 184 zName = blob_terminate(&a1);
184 zTarget = blob_terminate(&a2); 185 zTarget = blob_terminate(&a2);
> 186 blob_token(&line, &a3);
185 zSrc = blob_terminate(&a3); 187 zSrc = blob_terminate(&a3);
186 defossilize(zName); 188 defossilize(zName);
187 if( zName[0]!='+' && zName[0]!='-' ){ | 189 if( !file_is_simple_pathname(zName) ){
188 goto manifest_syntax_error; <
189 } <
190 if( !file_is_simple_pathname(&zName[1]) ){ <
191 goto manifest_syntax_error; 190 goto manifest_syntax_error;
192 } 191 }
193 defossilize(zTarget); 192 defossilize(zTarget);
194 if( (blob_size(&a2)!=UUID_SIZE || !validate16(zTarget, UUID_SIZE)) 193 if( (blob_size(&a2)!=UUID_SIZE || !validate16(zTarget, UUID_SIZE))
195 && !wiki_name_is_wellformed((const unsigned char *)zTarget) ){ 194 && !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
196 goto manifest_syntax_error; 195 goto manifest_syntax_error;
197 } 196 }
198 if( blob_size(&a3)!=UUID_SIZE ) goto manifest_syntax_error; | 197 if( blob_size(&a3)>0
199 if( !validate16(zSrc, UUID_SIZE) ) goto manifest_syntax_error; | 198 && (blob_size(&a3)!=UUID_SIZE || !validate16(zSrc, UUID_SIZE)) ){
> 199 goto manifest_syntax_error;
> 200 }
200 p->zAttachName = zName; 201 p->zAttachName = zName;
201 p->zAttachSrc = zSrc; 202 p->zAttachSrc = zSrc;
202 p->zAttachTarget = zTarget; 203 p->zAttachTarget = zTarget;
203 break; 204 break;
204 } 205 }
205 206
206 /* 207 /*
................................................................................................................................................................................
620 if( !seenZ ) goto manifest_syntax_error; 621 if( !seenZ ) goto manifest_syntax_error;
621 p->type = CFTYPE_CONTROL; 622 p->type = CFTYPE_CONTROL;
622 }else if( p->zAttachName ){ 623 }else if( p->zAttachName ){
623 if( p->nCChild>0 ) goto manifest_syntax_error; 624 if( p->nCChild>0 ) goto manifest_syntax_error;
624 if( p->rDate==0.0 ) goto manifest_syntax_error; 625 if( p->rDate==0.0 ) goto manifest_syntax_error;
625 if( p->zTicketUuid ) goto manifest_syntax_error; 626 if( p->zTicketUuid ) goto manifest_syntax_error;
626 if( p->zWikiTitle ) goto manifest_syntax_error; 627 if( p->zWikiTitle ) goto manifest_syntax_error;
> 628 if( !seenZ ) goto manifest_syntax_error;
627 p->type = CFTYPE_ATTACHMENT; 629 p->type = CFTYPE_ATTACHMENT;
628 }else{ 630 }else{
629 if( p->nCChild>0 ) goto manifest_syntax_error; 631 if( p->nCChild>0 ) goto manifest_syntax_error;
630 if( p->rDate<=0.0 ) goto manifest_syntax_error; 632 if( p->rDate<=0.0 ) goto manifest_syntax_error;
631 if( p->nParent>0 ) goto manifest_syntax_error; 633 if( p->nParent>0 ) goto manifest_syntax_error;
632 if( p->nField>0 ) goto manifest_syntax_error; 634 if( p->nField>0 ) goto manifest_syntax_error;
633 if( p->zTicketUuid ) goto manifest_syntax_error; 635 if( p->zTicketUuid ) goto manifest_syntax_error;
................................................................................................................................................................................
1112 1114
1113 assert( manifest_crosslink_busy==1 ); 1115 assert( manifest_crosslink_busy==1 );
1114 zTag = mprintf("tkt-%s", m.zTicketUuid); 1116 zTag = mprintf("tkt-%s", m.zTicketUuid);
1115 tag_insert(zTag, 1, 0, rid, m.rDate, rid); 1117 tag_insert(zTag, 1, 0, rid, m.rDate, rid);
1116 free(zTag); 1118 free(zTag);
1117 db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)", 1119 db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
1118 m.zTicketUuid); 1120 m.zTicketUuid);
> 1121 }
> 1122 if( m.type==CFTYPE_ATTACHMENT ){
> 1123 db_multi_exec(
> 1124 "INSERT OR IGNORE INTO attachment(mtime, target, filename)"
> 1125 "VALUES(0.0,%Q,%Q)",
> 1126 m.zAttachTarget, m.zAttachName
> 1127 );
> 1128 db_multi_exec(
> 1129 "UPDATE attachment SET mtime=%.17g, src=%Q, comment=%Q, user=%Q"
> 1130 " WHERE mtime<%.17g AND target=%Q AND filename=%Q",
> 1131 m.rDate, m.zAttachSrc, m.zComment, m.zUser,
> 1132 m.rDate, m.zAttachTarget, m.zAttachName
> 1133 );
1119 } 1134 }
1120 db_end_transaction(0); 1135 db_end_transaction(0);
1121 manifest_clear(&m); 1136 manifest_clear(&m);
1122 return 1; 1137 return 1;
1123 } 1138 }
Changes to src/schema.c
320 @ target TEXT, -- Where the hyperlink points to 320 @ target TEXT, -- Where the hyperlink points to
321 @ srctype INT, -- 0: check-in 1: ticket 2: wiki 321 @ srctype INT, -- 0: check-in 1: ticket 2: wiki
322 @ srcid INT, -- rid for checkin or wiki. tkt_id for ticket. 322 @ srcid INT, -- rid for checkin or wiki. tkt_id for ticket.
323 @ mtime TIMESTAMP, -- time that the hyperlink was added 323 @ mtime TIMESTAMP, -- time that the hyperlink was added
324 @ UNIQUE(target, srctype, srcid) 324 @ UNIQUE(target, srctype, srcid)
325 @ ); 325 @ );
326 @ CREATE INDEX backlink_src ON backlink(srcid, srctype); 326 @ CREATE INDEX backlink_src ON backlink(srcid, srctype);
> 327 @
> 328 @ -- Each attachment is an entry in the following table. Only
> 329 @ -- the most recent attachment (identified by the D card) is saved.
> 330 @ --
> 331 @ CREATE TABLE attachment(
> 332 @ mtime TIMESTAMP, -- Time when attachment last changed
> 333 @ src TEXT, -- UUID of the attachment. NULL to delete
> 334 @ target TEXT, -- Object attached to
> 335 @ filename TEXT, -- Filename for the attachment
> 336 @ comment TEXT, -- Comment associated with this attachment
> 337 @ user TEXT, -- Name of user adding attachment
> 338 @ PRIMARY KEY(target, filename)
> 339 @ );
327 @ 340 @
328 @ -- Template for the TICKET table 341 @ -- Template for the TICKET table
329 @ -- 342 @ --
330 @ -- NB: when changing the schema of the TICKET table here, also make the 343 @ -- NB: when changing the schema of the TICKET table here, also make the
331 @ -- same change in tktsetup.c. 344 @ -- same change in tktsetup.c.
332 @ -- 345 @ --
333 @ CREATE TABLE ticket( 346 @ CREATE TABLE ticket(
Changes to www/fileformat.wiki
378 378
379 An attachment artifact associates some other artifact that is the 379 An attachment artifact associates some other artifact that is the
380 attachment (the source artifact) with a ticket or wiki page to which 380 attachment (the source artifact) with a ticket or wiki page to which
381 the attachment is connected (the target artifact). 381 the attachment is connected (the target artifact).
382 The following cards are allowed on an attachment artifact: 382 The following cards are allowed on an attachment artifact:
383 383
384 <blockquote> 384 <blockquote>
385 <b>A</b> (<b>+</b>|<b>-</b>)<i>filename target source</i> | 385 <b>A</b> <i>filename target</i> ?<i>source</i>?
386 <b>C</b> <i>comment</i><br> 386 <b>C</b> <i>comment</i><br>
387 <b>D</b> <i>time-and-date-stamp</i><br /> 387 <b>D</b> <i>time-and-date-stamp</i><br />
388 <b>U</b> <i>user-name</i><br /> 388 <b>U</b> <i>user-name</i><br />
389 <b>Z</b> <i>checksum</i> 389 <b>Z</b> <i>checksum</i>
390 </blockquote> 390 </blockquote>
391 391
392 The A card specifies a filename for the attachment in its first argument. 392 The A card specifies a filename for the attachment in its first argument.
393 The filename is preceeded by "+" to add the attachment or "-" to | 393 The second argument to the A card is the name
394 remove the attachment. The second argument to the A card is the name <
395 of the wiki page or ticket to which the attachment is connected. The 394 of the wiki page or ticket to which the attachment is connected. The
396 third argument is is the 40-character artifact ID of the attachment | 395 third argument is either missing or else it is the 40-character artifact
397 itself. Every attachment artifact must have exactly one A card. | 396 ID of the attachment itself. A missing third argument means that the
> 397 attachment should be deleted.
398 398
399 The C card is an optional comment describing what the attachment is about. 399 The C card is an optional comment describing what the attachment is about.
400 The C card is optional, but there can only be one. 400 The C card is optional, but there can only be one.
401 401
402 A single D card is required to give the date and time when the attachment 402 A single D card is required to give the date and time when the attachment
403 was applied. 403 was applied.
404 404
................................................................................................................................................................................
424 <th>Cluster</th> 424 <th>Cluster</th>
425 <th>Control</th> 425 <th>Control</th>
426 <th>Wiki</th> 426 <th>Wiki</th>
427 <th>Ticket</th> 427 <th>Ticket</th>
428 <th>Attachment</th> 428 <th>Attachment</th>
429 </tr> 429 </tr>
430 <tr> 430 <tr>
431 <td><b>A</b> (<b>+</b>|<b>-</b>)<i>filename target source</i></td> | 431 <td><b>A</b> <i>filename target source</i></td>
432 <td> </td> 432 <td> </td>
433 <td> </td> 433 <td> </td>
434 <td> </td> 434 <td> </td>
435 <td> </td> 435 <td> </td>
436 <td> </td> 436 <td> </td>
437 <td align=center><b>X</b></td> 437 <td align=center><b>X</b></td>
438 </tr> 438 </tr>