| ︙ | | |
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
-
-
+
+
+
|
ManifestFile *pFile;
db_begin_transaction();
p = manifest_get(vid, CFTYPE_MANIFEST);
if( p==0 ) return;
db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
db_prepare(&ins,
"INSERT INTO vfile(vid,rid,mrid,pathname) "
" VALUES(:vid,:id,:id,:name)");
"INSERT INTO vfile(vid,rid,mrid,pathname,islink) "
" VALUES(:vid,:id,:id,:name,:islink)");
db_bind_int(&ins, ":vid", vid);
manifest_file_rewind(p);
while( (pFile = manifest_file_next(p,0))!=0 ){
if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
rid = uuid_to_rid(pFile->zUuid, 0);
if( rid==0 || db_int(-1, "SELECT size FROM blob WHERE rid=%d", rid)<0 ){
fossil_warning("content missing for %s", pFile->zName);
continue;
}
db_bind_int(&ins, ":id", rid);
db_bind_text(&ins, ":name", pFile->zName);
db_bind_int(&ins, ":islink", pFile->zPerm && strstr(pFile->zPerm, "l"));
db_step(&ins);
db_reset(&ins);
}
db_finalize(&ins);
manifest_destroy(p);
db_end_transaction(0);
}
|
| ︙ | | |
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
-
+
|
zName = db_column_text(&q, 1);
rid = db_column_int(&q, 2);
isDeleted = db_column_int(&q, 3);
oldChnged = db_column_int(&q, 4);
oldMtime = db_column_int64(&q, 7);
if( isDeleted ){
chnged = 1;
}else if( !file_isfile(zName) && file_size(0)>=0 ){
}else if( !file_isfile_or_link(zName) && file_size(0)>=0 ){
if( notFileIsFatal ){
fossil_warning("not an ordinary file: %s", zName);
nErr++;
}
chnged = 1;
}else if( oldChnged>=2 ){
chnged = oldChnged;
|
| ︙ | | |
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
-
+
-
+
-
+
+
|
int promptFlag /* Prompt user to confirm overwrites */
){
Stmt q;
Blob content;
int nRepos = strlen(g.zLocalRoot);
if( vid>0 && id==0 ){
db_prepare(&q, "SELECT id, %Q || pathname, mrid"
db_prepare(&q, "SELECT id, %Q || pathname, mrid, islink"
" FROM vfile"
" WHERE vid=%d AND mrid>0",
g.zLocalRoot, vid);
}else{
assert( vid==0 && id>0 );
db_prepare(&q, "SELECT id, %Q || pathname, mrid"
db_prepare(&q, "SELECT id, %Q || pathname, mrid, islink"
" FROM vfile"
" WHERE id=%d AND mrid>0",
g.zLocalRoot, id);
}
while( db_step(&q)==SQLITE_ROW ){
int id, rid;
int id, rid, isLink;
const char *zName;
id = db_column_int(&q, 0);
zName = db_column_text(&q, 1);
rid = db_column_int(&q, 2);
isLink = db_column_int(&q, 3);
content_get(rid, &content);
if( file_is_the_same(&content, zName) ){
blob_reset(&content);
continue;
}
if( promptFlag && file_size(zName)>=0 ){
Blob ans;
|
| ︙ | | |
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
+
+
+
+
+
+
+
+
+
+
-
+
+
|
}
if( cReply=='n' || cReply=='N' ){
blob_reset(&content);
continue;
}
}
if( verbose ) printf("%s\n", &zName[nRepos]);
if( file_isdir(zName) == 1 ){
//TODO remove directories?
fossil_fatal("%s is directory, cannot overwrite\n", zName);
}
if( file_size(zName)>=0 && (isLink || file_islink(zName)) ){
unlink(zName);
}
if( isLink ){
create_symlink(blob_str(&content), zName);
}else{
blob_write_to_file(&content, zName);
blob_write_to_file(&content, zName);
}
blob_reset(&content);
db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
file_mtime(zName), id);
}
db_finalize(&q);
}
|
| ︙ | | |
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
-
+
|
if( pEntry->d_name[1]==0 ) continue;
if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
}
blob_appendf(pPath, "/%s", pEntry->d_name);
zPath = blob_str(pPath);
if( file_isdir(zPath)==1 ){
vfile_scan(vid, pPath, nPrefix, allFlag);
}else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
}else if( file_isfile_or_link(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]);
}
blob_resize(pPath, origSize);
}
}
closedir(d);
}
|
| ︙ | | |
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
while( db_step(&q)==SQLITE_ROW ){
const char *zFullpath = db_column_text(&q, 0);
const char *zName = db_column_text(&q, 1);
int isSelected = db_column_int(&q, 3);
if( isSelected ){
md5sum_step_text(zName, -1);
if( file_islink(zFullpath) ){
/* Instead of file content, use link destination path */
Blob pathBuf;
sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n",
blob_read_link(&pathBuf, zFullpath));
md5sum_step_text(zBuf, -1);
md5sum_step_text(blob_str(&pathBuf), -1);
blob_reset(&pathBuf);
}else{
in = fopen(zFullpath,"rb");
if( in==0 ){
md5sum_step_text(" 0\n", -1);
continue;
}
fseek(in, 0L, SEEK_END);
sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", ftell(in));
fseek(in, 0L, SEEK_SET);
md5sum_step_text(zBuf, -1);
/*printf("%s %s %s",md5sum_current_state(),zName,zBuf); fflush(stdout);*/
for(;;){
int n;
n = fread(zBuf, 1, sizeof(zBuf), in);
if( n<=0 ) break;
md5sum_step_text(zBuf, n);
}
fclose(in);
in = fopen(zFullpath,"rb");
if( in==0 ){
md5sum_step_text(" 0\n", -1);
continue;
}
fseek(in, 0L, SEEK_END);
sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", ftell(in));
fseek(in, 0L, SEEK_SET);
md5sum_step_text(zBuf, -1);
/*printf("%s %s %s",md5sum_current_state(),zName,zBuf); fflush(stdout);*/
for(;;){
int n;
n = fread(zBuf, 1, sizeof(zBuf), in);
if( n<=0 ) break;
md5sum_step_text(zBuf, n);
}
fclose(in);
}
}else{
int rid = db_column_int(&q, 4);
const char *zOrigName = db_column_text(&q, 2);
char zBuf[100];
Blob file;
if( zOrigName ) zName = zOrigName;
|
| ︙ | | |
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
|
+
+
+
-
-
-
-
-
+
+
+
+
+
+
|
md5sum_init();
while( db_step(&q)==SQLITE_ROW ){
const char *zFullpath = db_column_text(&q, 0);
const char *zName = db_column_text(&q, 1);
int rid = db_column_int(&q, 2);
blob_zero(&disk);
if( file_islink(zFullpath) ){
blob_read_link(&disk, zFullpath);
}else{
rc = blob_read_from_file(&disk, zFullpath);
if( rc<0 ){
printf("ERROR: cannot read file [%s]\n", zFullpath);
blob_reset(&disk);
continue;
rc = blob_read_from_file(&disk, zFullpath);
if( rc<0 ){
printf("ERROR: cannot read file [%s]\n", zFullpath);
blob_reset(&disk);
continue;
}
}
blob_zero(&repo);
content_get(rid, &repo);
if( blob_size(&repo)!=blob_size(&disk) ){
printf("ERROR: [%s] is %d bytes on disk but %d in the repository\n",
zName, blob_size(&disk), blob_size(&repo));
blob_reset(&disk);
|
| ︙ | | |