Fossil SCM
Simplify vfile_dir_scan and make sure nested calls do not alter the path added to the dscan_temp table.
Commit
4f2bad8396b3b83387575aaca34f0a77d9d746b4
Parent
51403ee52e05833…
1 file changed
+4
-7
+4
-7
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -563,11 +563,11 @@ | ||
| 563 | 563 | " x TEXT PRIMARY KEY %s, y INTEGER)", |
| 564 | 564 | filename_collation()); |
| 565 | 565 | db_prepare(&ins, |
| 566 | 566 | "INSERT OR IGNORE INTO dscan_temp(x, y) SELECT :file, :count" |
| 567 | 567 | " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE" |
| 568 | - " pathname GLOB :pattern %s)", filename_collation() | |
| 568 | + " pathname GLOB :file || '/*' %s)", filename_collation() | |
| 569 | 569 | ); |
| 570 | 570 | db_prepare(&upd, |
| 571 | 571 | "UPDATE OR IGNORE dscan_temp SET y = coalesce(y, 0) + 1" |
| 572 | 572 | " WHERE x=:file %s", |
| 573 | 573 | filename_collation() |
| @@ -595,21 +595,18 @@ | ||
| 595 | 595 | glob_match(pIgnore2, &zPath[nPrefix+1]) || |
| 596 | 596 | glob_match(pIgnore3, &zPath[nPrefix+1]) ){ |
| 597 | 597 | /* do nothing */ |
| 598 | 598 | }else if( file_wd_isdir(zPath)==1 ){ |
| 599 | 599 | if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){ |
| 600 | - Blob dirPattern; | |
| 600 | + char *zSavePath = mprintf("%s", zPath); | |
| 601 | 601 | int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1, |
| 602 | 602 | pIgnore2, pIgnore3); |
| 603 | - blob_init(&dirPattern, &zPath[nPrefix+1], -1); | |
| 604 | - blob_appendf(&dirPattern, "*"); | |
| 605 | - db_bind_text(&ins, ":file", &zPath[nPrefix+1]); | |
| 603 | + db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]); | |
| 606 | 604 | db_bind_int(&ins, ":count", count); |
| 607 | - db_bind_text(&ins, ":pattern", blob_str(&dirPattern)); | |
| 608 | 605 | db_step(&ins); |
| 609 | 606 | db_reset(&ins); |
| 610 | - blob_reset(&dirPattern); | |
| 607 | + fossil_free(zSavePath); | |
| 611 | 608 | result += count; /* found X normal files? */ |
| 612 | 609 | } |
| 613 | 610 | }else if( file_wd_isfile_or_link(zPath) ){ |
| 614 | 611 | db_bind_text(&upd, ":file", zOrigPath); |
| 615 | 612 | db_step(&upd); |
| 616 | 613 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -563,11 +563,11 @@ | |
| 563 | " x TEXT PRIMARY KEY %s, y INTEGER)", |
| 564 | filename_collation()); |
| 565 | db_prepare(&ins, |
| 566 | "INSERT OR IGNORE INTO dscan_temp(x, y) SELECT :file, :count" |
| 567 | " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE" |
| 568 | " pathname GLOB :pattern %s)", filename_collation() |
| 569 | ); |
| 570 | db_prepare(&upd, |
| 571 | "UPDATE OR IGNORE dscan_temp SET y = coalesce(y, 0) + 1" |
| 572 | " WHERE x=:file %s", |
| 573 | filename_collation() |
| @@ -595,21 +595,18 @@ | |
| 595 | glob_match(pIgnore2, &zPath[nPrefix+1]) || |
| 596 | glob_match(pIgnore3, &zPath[nPrefix+1]) ){ |
| 597 | /* do nothing */ |
| 598 | }else if( file_wd_isdir(zPath)==1 ){ |
| 599 | if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){ |
| 600 | Blob dirPattern; |
| 601 | int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1, |
| 602 | pIgnore2, pIgnore3); |
| 603 | blob_init(&dirPattern, &zPath[nPrefix+1], -1); |
| 604 | blob_appendf(&dirPattern, "*"); |
| 605 | db_bind_text(&ins, ":file", &zPath[nPrefix+1]); |
| 606 | db_bind_int(&ins, ":count", count); |
| 607 | db_bind_text(&ins, ":pattern", blob_str(&dirPattern)); |
| 608 | db_step(&ins); |
| 609 | db_reset(&ins); |
| 610 | blob_reset(&dirPattern); |
| 611 | result += count; /* found X normal files? */ |
| 612 | } |
| 613 | }else if( file_wd_isfile_or_link(zPath) ){ |
| 614 | db_bind_text(&upd, ":file", zOrigPath); |
| 615 | db_step(&upd); |
| 616 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -563,11 +563,11 @@ | |
| 563 | " x TEXT PRIMARY KEY %s, y INTEGER)", |
| 564 | filename_collation()); |
| 565 | db_prepare(&ins, |
| 566 | "INSERT OR IGNORE INTO dscan_temp(x, y) SELECT :file, :count" |
| 567 | " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE" |
| 568 | " pathname GLOB :file || '/*' %s)", filename_collation() |
| 569 | ); |
| 570 | db_prepare(&upd, |
| 571 | "UPDATE OR IGNORE dscan_temp SET y = coalesce(y, 0) + 1" |
| 572 | " WHERE x=:file %s", |
| 573 | filename_collation() |
| @@ -595,21 +595,18 @@ | |
| 595 | glob_match(pIgnore2, &zPath[nPrefix+1]) || |
| 596 | glob_match(pIgnore3, &zPath[nPrefix+1]) ){ |
| 597 | /* do nothing */ |
| 598 | }else if( file_wd_isdir(zPath)==1 ){ |
| 599 | if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){ |
| 600 | char *zSavePath = mprintf("%s", zPath); |
| 601 | int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1, |
| 602 | pIgnore2, pIgnore3); |
| 603 | db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]); |
| 604 | db_bind_int(&ins, ":count", count); |
| 605 | db_step(&ins); |
| 606 | db_reset(&ins); |
| 607 | fossil_free(zSavePath); |
| 608 | result += count; /* found X normal files? */ |
| 609 | } |
| 610 | }else if( file_wd_isfile_or_link(zPath) ){ |
| 611 | db_bind_text(&upd, ":file", zOrigPath); |
| 612 | db_step(&upd); |
| 613 |