Fossil

Check-in [5d913409]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixes to the unversioned file sync protocol.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | unversioned-files
Files: files | file ages | folders
SHA1:5d913409b70a013d6fc7bd2463026f2bc0c86bd2
User & Date: drh 2016-08-09 17:18:56
Context
2016-08-09
17:31
Another unversioned file sync fix. check-in: a6b66652 user: drh tags: unversioned-files
17:18
Fixes to the unversioned file sync protocol. check-in: 5d913409 user: drh tags: unversioned-files
15:29
More work on unversioned file sync. check-in: a3dcfe75 user: drh tags: unversioned-files
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/xfer.c.

   368    368         "REPLACE INTO unversioned(name, rcvid, mtime, hash, sz, content)"
   369    369         " VALUES(:name,:rcvid,:mtime,:hash,:sz,:content)"
   370    370       );
   371    371     }
   372    372     db_bind_text(&q, ":name", blob_str(&pXfer->aToken[1]));
   373    373     db_bind_int(&q, ":rcvid", g.rcvid);
   374    374     db_bind_int64(&q, ":mtime", mtime);
   375         -  db_bind_text(&q, ":hash", blob_str(&pXfer->aToken[5]));
          375  +  db_bind_text(&q, ":hash", blob_str(pHash));
   376    376     db_bind_int(&q, ":sz", blob_size(&content));
   377    377     if( !nullContent ){
   378    378       blob_compress(&content, &content);
   379    379       db_bind_blob(&q, ":content", &content);
   380    380     }
   381    381     db_step(&q);
   382    382     db_finalize(&q);
................................................................................
   637    637   **
   638    638   ** If the noContent flag is set, omit the CONTENT and set the 0x0004 flag in FLAGS.
   639    639   */
   640    640   static void send_unversioned_file(Xfer *pXfer, const char *zName, int noContent){
   641    641     Stmt q1;
   642    642   
   643    643     if( noContent ){
   644         -    db_static_prepare(&q1,
          644  +    db_prepare(&q1,
   645    645         "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q",
   646    646         zName
   647    647       );
   648    648     }else{
   649         -    db_static_prepare(&q1,
          649  +    db_prepare(&q1,
   650    650         "SELECT mtime, hash, encoding, sz, content FROM unversioned WHERE name=%Q",
   651    651         zName
   652    652       );
   653    653     }
   654    654     if( db_step(&q1)==SQLITE_ROW ){
   655    655       sqlite3_int64 mtime = db_column_int64(&q1, 0);
   656    656       const char *zHash = db_column_text(&q1, 1);
................................................................................
  1836   1836       ** obsolete on the server.
  1837   1837       */
  1838   1838       if( uvDoPush ){
  1839   1839         Stmt uvq;
  1840   1840         assert( (syncFlags & SYNC_UNVERSIONED)!=0 );
  1841   1841         assert( uvStatus==2 );
  1842   1842         db_prepare(&uvq, "SELECT name, mtimeOnly FROM uv_tosend");
  1843         -      while( db_step(&uvq) ){
         1843  +      while( db_step(&uvq)==SQLITE_ROW ){
  1844   1844           send_unversioned_file(&xfer, db_column_text(&uvq,0), db_column_int(&uvq,1));
  1845   1845           nCardSent++;
  1846   1846         }
  1847   1847         db_finalize(&uvq);
  1848   1848         uvDoPush = 0;
  1849   1849       }
  1850   1850   
................................................................................
  1958   1958   
  1959   1959         /*   uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
  1960   1960         **
  1961   1961         ** Accept an unversioned file from the client.
  1962   1962         */
  1963   1963         if( blob_eq(&xfer.aToken[0], "uvfile") ){
  1964   1964           xfer_accept_unversioned_file(&xfer, 1);
         1965  +        nArtifactRcvd++;
  1965   1966         }else
  1966   1967   
  1967   1968         /*   gimme UUID
  1968   1969         **
  1969   1970         ** Server is requesting a file.  If the file is a manifest, assume
  1970   1971         ** that the server will also want to know all of the content files
  1971   1972         ** associated with the manifest and send those too.
................................................................................
  2032   2033           const char *zName = blob_str(&xfer.aToken[1]);
  2033   2034           const char *zHash = blob_str(&xfer.aToken[3]);
  2034   2035           int iStatus;
  2035   2036           if( uvStatus==0 ) uvStatus = 2;
  2036   2037           iStatus = unversioned_status(zName, mtime, zHash);
  2037   2038           if( iStatus<=1 ){
  2038   2039             if( zHash[0]!='-' ){
  2039         -            @ uvgimme %s(zName)
         2040  +            blob_appendf(xfer.pOut, "uvgimme %s\n", zName);
         2041  +            nCardSent++;
  2040   2042             }else if( iStatus==1 ){
  2041   2043               db_multi_exec(
  2042   2044                  "UPDATE unversioned"
  2043   2045                  "   SET mtime=%lld, hash=NULL, sz=0, encoding=0, content=NULL"
  2044   2046                  " WHERE name=%Q", mtime, zName
  2045   2047               );
  2046   2048               db_unset("uv-hash", 0);