Differences From:
File
src/vfile.c
part of check-in
[849b94c631]
- Avoid the use of chdir() since this seems to cause problems on windows.
by
drh on
2008-07-17 01:49:16.
[view]
To:
File
src/vfile.c
part of check-in
[2dffce041d]
- Add the ability to detect file changes using only the mtime. This is turned
on using the "fossil setting mtime-changes ON" command. It is off by default,
but it does make many operations go much faster, especially on large
repositories, so we might want to start turning it on by default.
by
drh on
2008-12-06 18:02:21.
[view]
@@ -146,37 +146,47 @@
*/
void vfile_check_signature(int vid){
Stmt q;
Blob fileCksum, origCksum;
+ int checkMtime = db_get_boolean("mtime-changes", 0);
db_begin_transaction();
db_prepare(&q, "SELECT id, %Q || pathname,"
- " vfile.mrid, deleted, chnged, uuid"
+ " vfile.mrid, deleted, chnged, uuid, mtime"
" FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid"
" WHERE vid=%d ", g.zLocalRoot, vid);
while( db_step(&q)==SQLITE_ROW ){
int id, rid, isDeleted;
const char *zName;
int chnged = 0;
int oldChnged;
+ i64 oldMtime;
+ i64 currentMtime;
id = db_column_int(&q, 0);
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, 6);
if( oldChnged>=2 ){
chnged = oldChnged;
}else if( isDeleted || rid==0 ){
chnged = 1;
}
if( chnged!=1 ){
+ currentMtime = file_mtime(zName);
+ }
+ if( chnged!=1 && (checkMtime==0 || currentMtime!=oldMtime) ){
db_ephemeral_blob(&q, 5, &origCksum);
if( sha1sum_file(zName, &fileCksum) ){
blob_zero(&fileCksum);
}
if( blob_compare(&fileCksum, &origCksum) ){
chnged = 1;
+ }else if( currentMtime!=oldMtime ){
+ db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
+ currentMtime, id);
}
blob_reset(&origCksum);
blob_reset(&fileCksum);
}
@@ -218,8 +228,10 @@
rid = db_column_int(&q, 2);
content_get(rid, &content);
if( verbose ) printf("%s\n", &zName[nRepos]);
blob_write_to_file(&content, zName);
+ db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
+ file_mtime(zName), id);
}
db_finalize(&q);
}
@@ -237,8 +249,9 @@
zName = db_column_text(&q, 0);
unlink(zName);
}
db_finalize(&q);
+ db_multi_exec("UPDATE vfile SET mtime=NULL HERE vid=%d AND mrid>0", vid);
}
/*
** Load into table SFILE the name of every ordinary file in