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

Overview
Comment:Delete records from the temporary table "pending" after sending them.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:23c8dad306718247d2abbc88c6a255c49ba1a460
User & Date: dan 2007-07-30 05:17:44
Context
2007-07-30
16:31
Merge in clone and sync changes. Fix a bug in undelta. check-in: e3c529c2 user: dan tags: trunk
05:17
Delete records from the temporary table "pending" after sending them. check-in: 23c8dad3 user: dan tags: trunk
2007-07-28
08:15
Fix to the db_open_local() function in the case where the root directory is writable by the current user. check-in: d0d4c5f5 user: dan tags: trunk
Changes

Changes to src/xfer.c.

127
128
129
130
131
132
133

134
135
136
137
138
139
140
...
154
155
156
157
158
159
160
161
162
163
164
165
166

167
168
169
170
171
172
173
...
175
176
177
178
179
180
181







182
183
184
185
186
187
188
}


/*
** Send all pending files.
*/
static int send_all_pending(Blob *pOut){

  int sent = 0;
  int nSent = 0;
  int maxSize = db_get_int("http-msg-size", 1000000);
  Stmt q;
#if 0
  db_multi_exec(
    "CREATE TEMP TABLE priority(rid INTEGER PRIMARY KEY);"
................................................................................
      " SELECT srcid FROM delta WHERE rid=%d"
      " UNION ALL"
      " SELECT rid FROM delta WHERE srcid=%d",
      rid, rid
    );
  }
#endif
  db_prepare(&q, "SELECT rid FROM pending");
  while( db_step(&q)==SQLITE_ROW ){
    int rid = db_column_int(&q, 0);
    if( sent<maxSize ){
      sent += send_file(rid, pOut);
      nSent++;

    }else{
      char *zUuid = db_text(0,
                      "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
      if( zUuid ){
        if( pOut ){
          blob_appendf(pOut, "igot %s\n", zUuid);
        }else{
................................................................................
        }
        free(zUuid);
      }
    }
  }
  db_finalize(&q);
  







#if 0
  db_multi_exec("DROP TABLE priority");
#endif
  return nSent;
}









>







 







|





>







 







>
>
>
>
>
>
>







127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
}


/*
** Send all pending files.
*/
static int send_all_pending(Blob *pOut){
  int iRidSent = 0;
  int sent = 0;
  int nSent = 0;
  int maxSize = db_get_int("http-msg-size", 1000000);
  Stmt q;
#if 0
  db_multi_exec(
    "CREATE TEMP TABLE priority(rid INTEGER PRIMARY KEY);"
................................................................................
      " SELECT srcid FROM delta WHERE rid=%d"
      " UNION ALL"
      " SELECT rid FROM delta WHERE srcid=%d",
      rid, rid
    );
  }
#endif
  db_prepare(&q, "SELECT rid FROM pending ORDER BY rid");
  while( db_step(&q)==SQLITE_ROW ){
    int rid = db_column_int(&q, 0);
    if( sent<maxSize ){
      sent += send_file(rid, pOut);
      nSent++;
      iRidSent = rid;
    }else{
      char *zUuid = db_text(0,
                      "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
      if( zUuid ){
        if( pOut ){
          blob_appendf(pOut, "igot %s\n", zUuid);
        }else{
................................................................................
        }
        free(zUuid);
      }
    }
  }
  db_finalize(&q);
  
  /* Delete the 'pending' records for all files just sent. Otherwise,
  ** we can wind up sending some files more than once.
  */
  if( nSent>0 ){
    db_multi_exec("DELETE FROM pending WHERE rid <= %d", iRidSent);
  }

#if 0
  db_multi_exec("DROP TABLE priority");
#endif
  return nSent;
}