| | @@ -85,132 +85,77 @@ |
| 85 | 85 | zAll = blob_str(&x); |
| 86 | 86 | } |
| 87 | 87 | return zAll; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | | - |
| 91 | | -/* |
| 92 | | -** The pIgnore statement is query of the form: |
| 93 | | -** |
| 94 | | -** SELECT (:x GLOB ... OR :x GLOB ... OR ...) |
| 95 | | -** |
| 96 | | -** In other words, it is a query that returns true if the :x value |
| 97 | | -** should be ignored. Evaluate the query and return true to ignore |
| 98 | | -** and false to not ignore. |
| 99 | | -** |
| 100 | | -** If pIgnore is NULL, then do not ignore. |
| 101 | | -*/ |
| 102 | | -static int shouldBeIgnored(Stmt *pIgnore, const char *zName){ |
| 103 | | - int rc = 0; |
| 104 | | - if( pIgnore ){ |
| 105 | | - db_bind_text(pIgnore, ":x", zName); |
| 106 | | - db_step(pIgnore); |
| 107 | | - rc = db_column_int(pIgnore, 0); |
| 108 | | - db_reset(pIgnore); |
| 109 | | - } |
| 110 | | - return rc; |
| 111 | | -} |
| 112 | | - |
| 113 | | - |
| 114 | 90 | /* |
| 115 | 91 | ** Add a single file named zName to the VFILE table with vid. |
| 116 | 92 | ** |
| 117 | 93 | ** Omit any file whose name is pOmit. |
| 118 | 94 | */ |
| 119 | | -static void add_one_file( |
| 120 | | - const char *zName, /* Name of file to add */ |
| 121 | | - int vid, /* Add to this VFILE */ |
| 122 | | - Blob *pOmit |
| 123 | | -){ |
| 124 | | - Blob pathname; |
| 125 | | - const char *zPath; |
| 126 | | - int i; |
| 127 | | - const char *zReserved; |
| 128 | | - |
| 129 | | - file_tree_name(zName, &pathname, 1); |
| 130 | | - zPath = blob_str(&pathname); |
| 131 | | - for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ |
| 132 | | - if( fossil_strcmp(zPath, zReserved)==0 ) break; |
| 133 | | - } |
| 134 | | - if( zReserved || (pOmit && blob_compare(&pathname, pOmit)==0) ){ |
| 135 | | - fossil_warning("cannot add %s", zPath); |
| 136 | | - }else{ |
| 137 | | - if( !file_is_simple_pathname(zPath) ){ |
| 138 | | - fossil_fatal("filename contains illegal characters: %s", zPath); |
| 139 | | - } |
| 140 | | -#if defined(_WIN32) |
| 141 | | - if( db_exists("SELECT 1 FROM vfile" |
| 142 | | - " WHERE pathname=%Q COLLATE nocase", zPath) ){ |
| 143 | | - db_multi_exec("UPDATE vfile SET deleted=0" |
| 144 | | - " WHERE pathname=%Q COLLATE nocase", zPath); |
| 145 | | - } |
| 146 | | -#else |
| 147 | | - if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ |
| 148 | | - db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); |
| 149 | | - } |
| 150 | | -#endif |
| 151 | | - else{ |
| 152 | | - db_multi_exec( |
| 153 | | - "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" |
| 154 | | - "VALUES(%d,0,0,0,%Q,%d)", |
| 155 | | - vid, zPath,file_isexe(zName)); |
| 156 | | - } |
| 157 | | - printf("ADDED %s\n", zPath); |
| 158 | | - } |
| 159 | | - blob_reset(&pathname); |
| 160 | | -} |
| 161 | | - |
| 162 | | -/* |
| 163 | | -** All content of the zDir directory to the SFILE table. |
| 164 | | -*/ |
| 165 | | -void add_directory_content(const char *zDir, Stmt *pIgnore){ |
| 166 | | - DIR *d; |
| 167 | | - int origSize; |
| 168 | | - struct dirent *pEntry; |
| 169 | | - Blob path; |
| 170 | | - |
| 171 | | - blob_zero(&path); |
| 172 | | - blob_append(&path, zDir, -1); |
| 173 | | - origSize = blob_size(&path); |
| 174 | | - d = opendir(zDir); |
| 175 | | - if( d ){ |
| 176 | | - while( (pEntry=readdir(d))!=0 ){ |
| 177 | | - char *zPath; |
| 178 | | - if( pEntry->d_name[0]=='.' ){ |
| 179 | | - if( !includeDotFiles ) continue; |
| 180 | | - if( pEntry->d_name[1]==0 ) continue; |
| 181 | | - if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 182 | | - } |
| 183 | | - blob_appendf(&path, "/%s", pEntry->d_name); |
| 184 | | - zPath = blob_str(&path); |
| 185 | | - if( shouldBeIgnored(pIgnore, zPath) ){ |
| 186 | | - /* Noop */ |
| 187 | | - }else if( file_isdir(zPath)==1 ){ |
| 188 | | - add_directory_content(zPath, pIgnore); |
| 189 | | - }else if( file_isfile(zPath) ){ |
| 190 | | - db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath); |
| 191 | | - } |
| 192 | | - blob_resize(&path, origSize); |
| 193 | | - } |
| 194 | | - closedir(d); |
| 195 | | - } |
| 196 | | - blob_reset(&path); |
| 197 | | -} |
| 198 | | - |
| 199 | | -/* |
| 200 | | -** Add all content of a directory. |
| 201 | | -*/ |
| 202 | | -void add_directory(const char *zDir, int vid, Blob *pOmit, Stmt *pIgnore){ |
| 203 | | - Stmt q; |
| 204 | | - add_directory_content(zDir, pIgnore); |
| 205 | | - db_prepare(&q, "SELECT x FROM sfile ORDER BY x"); |
| 206 | | - while( db_step(&q)==SQLITE_ROW ){ |
| 207 | | - const char *zName = db_column_text(&q, 0); |
| 208 | | - add_one_file(zName, vid, pOmit); |
| 209 | | - } |
| 210 | | - db_finalize(&q); |
| 211 | | - db_multi_exec("DELETE FROM sfile"); |
| 95 | +static int add_one_file( |
| 96 | + const char *zPath, /* Tree-name of file to add. */ |
| 97 | + int vid /* Add to this VFILE */ |
| 98 | +){ |
| 99 | + if( !file_is_simple_pathname(zPath) ){ |
| 100 | + fossil_fatal("filename contains illegal characters: %s", zPath); |
| 101 | + } |
| 102 | +#if defined(_WIN32) |
| 103 | + if( db_exists("SELECT 1 FROM vfile" |
| 104 | + " WHERE pathname=%Q COLLATE nocase", zPath) ){ |
| 105 | + db_multi_exec("UPDATE vfile SET deleted=0" |
| 106 | + " WHERE pathname=%Q COLLATE nocase", zPath); |
| 107 | + } |
| 108 | +#else |
| 109 | + if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ |
| 110 | + db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); |
| 111 | + } |
| 112 | +#endif |
| 113 | + else{ |
| 114 | + char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); |
| 115 | + db_multi_exec( |
| 116 | + "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" |
| 117 | + "VALUES(%d,0,0,0,%Q,%d)", |
| 118 | + vid, zPath, file_isexe(zFullname)); |
| 119 | + fossil_free(zFullname); |
| 120 | + } |
| 121 | + printf("ADDED %s\n", zPath); |
| 122 | + return 1; |
| 123 | +} |
| 124 | + |
| 125 | +/* |
| 126 | +** Add all files in the sfile temp table. |
| 127 | +** |
| 128 | +** Automatically exclude the repository file. |
| 129 | +*/ |
| 130 | +static int add_files_in_sfile(int vid){ |
| 131 | + const char *zRepo; /* Name of the repository database file */ |
| 132 | + int nAdd = 0; /* Number of files added */ |
| 133 | + int i; /* Loop counter */ |
| 134 | + const char *zReserved; /* Name of a reserved file */ |
| 135 | + Blob repoName; /* Treename of the repository */ |
| 136 | + Stmt loop; /* SQL to loop over all files to add */ |
| 137 | + |
| 138 | + if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ |
| 139 | + blob_zero(&repoName); |
| 140 | + zRepo = ""; |
| 141 | + }else{ |
| 142 | + zRepo = blob_str(&repoName); |
| 143 | + } |
| 144 | + db_prepare(&loop, "SELECT x FROM sfile ORDER BY x"); |
| 145 | + while( db_step(&loop)==SQLITE_ROW ){ |
| 146 | + const char *zToAdd = db_column_text(&loop, 0); |
| 147 | + if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; |
| 148 | + for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ |
| 149 | + if( fossil_strcmp(zToAdd, zReserved)==0 ) break; |
| 150 | + } |
| 151 | + if( zReserved ) continue; |
| 152 | + nAdd += add_one_file(zToAdd, vid); |
| 153 | + } |
| 154 | + db_finalize(&loop); |
| 155 | + blob_reset(&repoName); |
| 156 | + return nAdd; |
| 212 | 157 | } |
| 213 | 158 | |
| 214 | 159 | /* |
| 215 | 160 | ** COMMAND: add |
| 216 | 161 | ** |
| | @@ -221,26 +166,24 @@ |
| 221 | 166 | ** |
| 222 | 167 | ** When adding files or directories recursively, filenames that begin |
| 223 | 168 | ** with "." are excluded by default. To include such files, add |
| 224 | 169 | ** the "--dotfiles" option to the command-line. |
| 225 | 170 | ** |
| 226 | | -** The --ignore option specifies the patterns for files to be excluded, |
| 227 | | -** like *.o,*.obj,*.exe. If not specified, the "ignore-glob" setting is |
| 228 | | -** used. See ** documentation on the "settings" command for further |
| 229 | | -** information. |
| 230 | | -** |
| 171 | +** The --ignore option is a comma-separate list of glob patterns for files |
| 172 | +** to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore option |
| 173 | +** does not appear on the command line then the "ignore-glob" setting is |
| 174 | +** used. |
| 231 | 175 | ** |
| 232 | 176 | ** SUMMARY: fossil add ?OPTIONS? FILE1 ?FILE2 ...? |
| 233 | 177 | ** Options: --dotfiles, --ignore |
| 234 | 178 | */ |
| 235 | 179 | void add_cmd(void){ |
| 236 | | - int i; |
| 237 | | - int vid; |
| 238 | | - const char *zIgnoreFlag; |
| 239 | | - Blob repo; |
| 240 | | - Stmt ignoreTest; /* Test to see if a name should be ignored */ |
| 241 | | - Stmt *pIgnore; /* Pointer to ignoreTest or to NULL */ |
| 180 | + int i; /* Loop counter */ |
| 181 | + int vid; /* Currently checked out version */ |
| 182 | + int nRoot; /* Full path characters in g.zLocalRoot */ |
| 183 | + const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 184 | + Glob *pIgnore; /* Ignore everything matching this glob pattern */ |
| 242 | 185 | |
| 243 | 186 | zIgnoreFlag = find_option("ignore",0,1); |
| 244 | 187 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 245 | 188 | db_must_be_within_tree(); |
| 246 | 189 | if( zIgnoreFlag==0 ){ |
| | @@ -249,101 +192,49 @@ |
| 249 | 192 | vid = db_lget_int("checkout",0); |
| 250 | 193 | if( vid==0 ){ |
| 251 | 194 | fossil_panic("no checkout to add to"); |
| 252 | 195 | } |
| 253 | 196 | db_begin_transaction(); |
| 254 | | - if( !file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 255 | | - blob_zero(&repo); |
| 256 | | - } |
| 257 | 197 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 258 | 198 | #if defined(_WIN32) |
| 259 | 199 | db_multi_exec( |
| 260 | 200 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 261 | 201 | " ON vfile(pathname COLLATE nocase)" |
| 262 | 202 | ); |
| 263 | 203 | #endif |
| 264 | | - if( zIgnoreFlag && zIgnoreFlag[0] ){ |
| 265 | | - db_prepare(&ignoreTest, "SELECT %s", glob_expr(":x", zIgnoreFlag)); |
| 266 | | - pIgnore = &ignoreTest; |
| 267 | | - }else{ |
| 268 | | - pIgnore = 0; |
| 269 | | - } |
| 204 | + pIgnore = glob_create(zIgnoreFlag); |
| 205 | + nRoot = strlen(g.zLocalRoot); |
| 206 | + |
| 207 | + /* Load the names of all files that are to be added into sfile temp table */ |
| 270 | 208 | for(i=2; i<g.argc; i++){ |
| 271 | 209 | char *zName; |
| 272 | 210 | int isDir; |
| 211 | + Blob fullName; |
| 273 | 212 | |
| 274 | | - zName = mprintf("%/", g.argv[i]); |
| 213 | + file_canonical_name(g.argv[i], &fullName); |
| 214 | + zName = blob_str(&fullName); |
| 275 | 215 | isDir = file_isdir(zName); |
| 276 | 216 | if( isDir==1 ){ |
| 277 | | - int sz = strlen(zName); |
| 278 | | - if( sz>0 && zName[sz-1]=='/' ){ zName[sz-1] = 0; } |
| 279 | | - add_directory(zName, vid, &repo, pIgnore); |
| 217 | + vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore); |
| 280 | 218 | }else if( isDir==0 ){ |
| 281 | 219 | fossil_fatal("not found: %s", zName); |
| 282 | 220 | }else if( access(zName, R_OK) ){ |
| 283 | 221 | fossil_fatal("cannot open %s", zName); |
| 284 | 222 | }else{ |
| 285 | | - add_one_file(zName, vid, &repo); |
| 223 | + char *zTreeName = &zName[nRoot]; |
| 224 | + db_multi_exec( |
| 225 | + "INSERT OR IGNORE INTO sfile(x)" |
| 226 | + " SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)", |
| 227 | + zTreeName, zTreeName |
| 228 | + ); |
| 286 | 229 | } |
| 287 | 230 | free(zName); |
| 288 | 231 | } |
| 289 | | - if( pIgnore ) db_finalize(pIgnore); |
| 290 | | - db_end_transaction(0); |
| 291 | | -} |
| 292 | | - |
| 293 | | - |
| 294 | | -/* |
| 295 | | -** Unmangage a single file. |
| 296 | | -*/ |
| 297 | | -void delete_one_file(const char *zName){ |
| 298 | | - char *zPath; |
| 299 | | - Blob pathname; |
| 300 | | - file_tree_name(zName, &pathname, 1); |
| 301 | | - zPath = blob_str(&pathname); |
| 302 | | - if( !db_exists( |
| 303 | | - "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ |
| 304 | | - fossil_fatal("not in the repository: %s", zName); |
| 305 | | - }else{ |
| 306 | | - db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); |
| 307 | | - printf("DELETED %s\n", zPath); |
| 308 | | - } |
| 309 | | - blob_reset(&pathname); |
| 310 | | -} |
| 311 | | - |
| 312 | | -/* |
| 313 | | -** Remove all contents of zDir |
| 314 | | -*/ |
| 315 | | -void del_directory_content(const char *zDir){ |
| 316 | | - DIR *d; |
| 317 | | - int origSize; |
| 318 | | - struct dirent *pEntry; |
| 319 | | - Blob path; |
| 320 | | - |
| 321 | | - blob_zero(&path); |
| 322 | | - blob_append(&path, zDir, -1); |
| 323 | | - origSize = blob_size(&path); |
| 324 | | - d = opendir(zDir); |
| 325 | | - if( d ){ |
| 326 | | - while( (pEntry=readdir(d))!=0 ){ |
| 327 | | - char *zPath; |
| 328 | | - if( pEntry->d_name[0]=='.'){ |
| 329 | | - if( !includeDotFiles ) continue; |
| 330 | | - if( pEntry->d_name[1]==0 ) continue; |
| 331 | | - if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 332 | | - } |
| 333 | | - blob_appendf(&path, "/%s", pEntry->d_name); |
| 334 | | - zPath = blob_str(&path); |
| 335 | | - if( file_isdir(zPath)==1 ){ |
| 336 | | - del_directory_content(zPath); |
| 337 | | - }else if( file_isfile(zPath) ){ |
| 338 | | - delete_one_file(zPath); |
| 339 | | - } |
| 340 | | - blob_resize(&path, origSize); |
| 341 | | - } |
| 342 | | - closedir(d); |
| 343 | | - } |
| 344 | | - blob_reset(&path); |
| 232 | + glob_free(pIgnore); |
| 233 | + |
| 234 | + add_files_in_sfile(vid); |
| 235 | + db_end_transaction(0); |
| 345 | 236 | } |
| 346 | 237 | |
| 347 | 238 | /* |
| 348 | 239 | ** COMMAND: rm |
| 349 | 240 | ** COMMAND: delete |
| | @@ -361,31 +252,45 @@ |
| 361 | 252 | ** or: fossil delete FILE1 ?FILE2 ...? |
| 362 | 253 | */ |
| 363 | 254 | void delete_cmd(void){ |
| 364 | 255 | int i; |
| 365 | 256 | int vid; |
| 257 | + Stmt loop; |
| 366 | 258 | |
| 367 | 259 | db_must_be_within_tree(); |
| 368 | 260 | vid = db_lget_int("checkout", 0); |
| 369 | 261 | if( vid==0 ){ |
| 370 | 262 | fossil_panic("no checkout to remove from"); |
| 371 | 263 | } |
| 372 | 264 | db_begin_transaction(); |
| 265 | + db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 373 | 266 | for(i=2; i<g.argc; i++){ |
| 374 | | - char *zName; |
| 375 | | - |
| 376 | | - zName = mprintf("%/", g.argv[i]); |
| 377 | | - if( file_isdir(zName) == 1 ){ |
| 378 | | - int sz = strlen(zName); |
| 379 | | - if( sz>0 && zName[sz-1]=='/' ){ zName[sz-1] = 0; } |
| 380 | | - del_directory_content(zName); |
| 381 | | - } else { |
| 382 | | - delete_one_file(zName); |
| 383 | | - } |
| 384 | | - free(zName); |
| 385 | | - } |
| 386 | | - db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); |
| 267 | + Blob treeName; |
| 268 | + char *zTreeName; |
| 269 | + |
| 270 | + file_tree_name(g.argv[i], &treeName, 1); |
| 271 | + zTreeName = blob_str(&treeName); |
| 272 | + db_multi_exec( |
| 273 | + "INSERT OR IGNORE INTO sfile" |
| 274 | + " SELECT pathname FROM vfile" |
| 275 | + " WHERE (pathname=%Q" |
| 276 | + " OR (pathname>'%q/' AND pathname<'%q0'))" |
| 277 | + " AND NOT deleted", |
| 278 | + zTreeName, zTreeName, zTreeName |
| 279 | + ); |
| 280 | + blob_reset(&treeName); |
| 281 | + } |
| 282 | + |
| 283 | + db_prepare(&loop, "SELECT x FROM sfile"); |
| 284 | + while( db_step(&loop)==SQLITE_ROW ){ |
| 285 | + printf("DELETED %s\n", db_column_text(&loop, 0)); |
| 286 | + } |
| 287 | + db_finalize(&loop); |
| 288 | + db_multi_exec( |
| 289 | + "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;" |
| 290 | + "DELETE FROM vfile WHERE rid=0 AND deleted;" |
| 291 | + ); |
| 387 | 292 | db_end_transaction(0); |
| 388 | 293 | } |
| 389 | 294 | |
| 390 | 295 | /* |
| 391 | 296 | ** COMMAND: addremove |
| | @@ -426,13 +331,13 @@ |
| 426 | 331 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 427 | 332 | int isTest = find_option("test",0,0)!=0; |
| 428 | 333 | int n; |
| 429 | 334 | Stmt q; |
| 430 | 335 | int vid; |
| 431 | | - Blob repo; |
| 432 | 336 | int nAdd = 0; |
| 433 | 337 | int nDelete = 0; |
| 338 | + Glob *pIgnore; |
| 434 | 339 | |
| 435 | 340 | db_must_be_within_tree(); |
| 436 | 341 | if( zIgnoreFlag==0 ){ |
| 437 | 342 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 438 | 343 | } |
| | @@ -439,38 +344,30 @@ |
| 439 | 344 | vid = db_lget_int("checkout",0); |
| 440 | 345 | if( vid==0 ){ |
| 441 | 346 | fossil_panic("no checkout to add to"); |
| 442 | 347 | } |
| 443 | 348 | db_begin_transaction(); |
| 349 | + |
| 350 | + /* step 1: |
| 351 | + ** Populate the temp table "sfile" with the names of all unmanged |
| 352 | + ** files currently in the check-out, except for files that match the |
| 353 | + ** --ignore or ignore-glob patterns and dot-files. Then add all of |
| 354 | + ** the files in the sfile temp table to the set of managed files. |
| 355 | + */ |
| 444 | 356 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 445 | 357 | n = strlen(g.zLocalRoot); |
| 446 | 358 | blob_init(&path, g.zLocalRoot, n-1); |
| 447 | 359 | /* now we read the complete file structure into a temp table */ |
| 448 | | - vfile_scan(0, &path, blob_size(&path), allFlag); |
| 449 | | - if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 450 | | - db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 451 | | - } |
| 452 | | - |
| 453 | | - /* step 1: search for extra files */ |
| 454 | | - db_prepare(&q, |
| 455 | | - "SELECT x, %Q || x FROM sfile" |
| 456 | | - " WHERE x NOT IN (%s)" |
| 457 | | - " AND NOT %s" |
| 458 | | - " ORDER BY 1", |
| 459 | | - g.zLocalRoot, |
| 460 | | - fossil_all_reserved_names(), |
| 461 | | - glob_expr("x", zIgnoreFlag) |
| 462 | | - ); |
| 463 | | - while( db_step(&q)==SQLITE_ROW ){ |
| 464 | | - add_one_file(db_column_text(&q, 1), vid, 0); |
| 465 | | - nAdd++; |
| 466 | | - } |
| 467 | | - db_finalize(&q); |
| 360 | + pIgnore = glob_create(zIgnoreFlag); |
| 361 | + vfile_scan(&path, blob_size(&path), allFlag, pIgnore); |
| 362 | + glob_free(pIgnore); |
| 363 | + nAdd = add_files_in_sfile(vid); |
| 364 | + |
| 468 | 365 | /* step 2: search for missing files */ |
| 469 | 366 | db_prepare(&q, |
| 470 | | - "SELECT pathname,%Q || pathname,deleted FROM vfile" |
| 471 | | - " WHERE deleted!=1" |
| 367 | + "SELECT pathname, %Q || pathname, deleted FROM vfile" |
| 368 | + " WHERE NOT deleted" |
| 472 | 369 | " ORDER BY 1", |
| 473 | 370 | g.zLocalRoot |
| 474 | 371 | ); |
| 475 | 372 | while( db_step(&q)==SQLITE_ROW ){ |
| 476 | 373 | const char * zFile; |
| | @@ -572,13 +469,13 @@ |
| 572 | 469 | zOrig = blob_str(&orig); |
| 573 | 470 | nOrig = blob_size(&orig); |
| 574 | 471 | db_prepare(&q, |
| 575 | 472 | "SELECT pathname FROM vfile" |
| 576 | 473 | " WHERE vid=%d" |
| 577 | | - " AND (pathname='%s' OR pathname GLOB '%s/*')" |
| 474 | + " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))" |
| 578 | 475 | " ORDER BY 1", |
| 579 | | - vid, zOrig, zOrig |
| 476 | + vid, zOrig, zOrig, zOrig |
| 580 | 477 | ); |
| 581 | 478 | while( db_step(&q)==SQLITE_ROW ){ |
| 582 | 479 | const char *zPath = db_column_text(&q, 0); |
| 583 | 480 | int nPath = db_column_bytes(&q, 0); |
| 584 | 481 | const char *zTail; |
| 585 | 482 | |