Fossil

Diff
Login

Differences From Artifact [279a96c412]:

To Artifact [b240f7c6f8]:


164
165
166
167
168
169
170
171

172
173
174



175
176
177
178
179
180
181
182
183
184

185
186
187
188
189
190

191
192
193
194
195
196
197
198
199




200
201
202
203
204
205
206
164
165
166
167
168
169
170

171
172
173

174
175
176
177
178
179
180
181
182

183
184
185
186
187
188




189
190
191
192
193
194
195
196


197
198
199
200
201
202
203
204
205
206
207







-
+


-
+
+
+






-



+


-
-
-
-
+







-
-
+
+
+
+







      goto manifest_syntax_error;
    }
    cPrevType = z[0];
    seenHeader = 1;
    if( blob_token(&line, &token)!=1 ) goto manifest_syntax_error;
    switch( z[0] ){
      /*
      **     A (+|-)<filename> target source
      **     A <filename> <target> ?<source>?
      **
      ** Identifies an attachment to either a wiki page or a ticket.
      ** <uuid> is the artifact that is the attachment.
      ** <source> is the artifact that is the attachment.  <source>
      ** is omitted to delete an attachment.  <target> is the name of
      ** a wiki page or ticket to which that attachment is connected.
      */
      case 'A': {
        char *zName, *zTarget, *zSrc;
        md5sum_step_text(blob_buffer(&line), blob_size(&line));
        if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
        if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
        if( blob_token(&line, &a3)==0 ) goto manifest_syntax_error;
        if( p->zAttachName!=0 ) goto manifest_syntax_error;
        zName = blob_terminate(&a1);
        zTarget = blob_terminate(&a2);
        blob_token(&line, &a3);
        zSrc = blob_terminate(&a3);
        defossilize(zName);
        if( zName[0]!='+' && zName[0]!='-' ){
          goto manifest_syntax_error;
        }
        if( !file_is_simple_pathname(&zName[1]) ){
        if( !file_is_simple_pathname(zName) ){
          goto manifest_syntax_error;
        }
        defossilize(zTarget);
        if( (blob_size(&a2)!=UUID_SIZE || !validate16(zTarget, UUID_SIZE))
           && !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
          goto manifest_syntax_error;
        }
        if( blob_size(&a3)!=UUID_SIZE ) goto manifest_syntax_error;
        if( !validate16(zSrc, UUID_SIZE) ) goto manifest_syntax_error;
        if( blob_size(&a3)>0
         && (blob_size(&a3)!=UUID_SIZE || !validate16(zSrc, UUID_SIZE)) ){
          goto manifest_syntax_error;
        }
        p->zAttachName = zName;
        p->zAttachSrc = zSrc;
        p->zAttachTarget = zTarget;
        break;
      }

      /*
620
621
622
623
624
625
626

627
628
629
630
631
632
633
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635







+







    if( !seenZ ) goto manifest_syntax_error;
    p->type = CFTYPE_CONTROL;
  }else if( p->zAttachName ){
    if( p->nCChild>0 ) goto manifest_syntax_error;
    if( p->rDate==0.0 ) goto manifest_syntax_error;
    if( p->zTicketUuid ) goto manifest_syntax_error;
    if( p->zWikiTitle ) goto manifest_syntax_error;
    if( !seenZ ) goto manifest_syntax_error;
    p->type = CFTYPE_ATTACHMENT;
  }else{
    if( p->nCChild>0 ) goto manifest_syntax_error;
    if( p->rDate<=0.0 ) goto manifest_syntax_error;
    if( p->nParent>0 ) goto manifest_syntax_error;
    if( p->nField>0 ) goto manifest_syntax_error;
    if( p->zTicketUuid ) goto manifest_syntax_error;
1112
1113
1114
1115
1116
1117
1118













1119
1120
1121
1122
1123
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138







+
+
+
+
+
+
+
+
+
+
+
+
+






    assert( manifest_crosslink_busy==1 );
    zTag = mprintf("tkt-%s", m.zTicketUuid);
    tag_insert(zTag, 1, 0, rid, m.rDate, rid);
    free(zTag);
    db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
                  m.zTicketUuid);
  }
  if( m.type==CFTYPE_ATTACHMENT ){
    db_multi_exec(
       "INSERT OR IGNORE INTO attachment(mtime, target, filename)"
       "VALUES(0.0,%Q,%Q)",
       m.zAttachTarget, m.zAttachName
    );
    db_multi_exec(
       "UPDATE attachment SET mtime=%.17g, src=%Q, comment=%Q, user=%Q"
       " WHERE mtime<%.17g AND target=%Q AND filename=%Q",
       m.rDate, m.zAttachSrc, m.zComment, m.zUser,
       m.rDate, m.zAttachTarget, m.zAttachName
    );
  }
  db_end_transaction(0);
  manifest_clear(&m);
  return 1;
}