Fossil SCM
Fix the empty-dirs property so that creates the complete path of directories, not just leaves, and so that it does not leak memory.
Commit
702331e057f6ec35d93ec0c12d9f4721d5b6d74c
Parent
48499514cc69c77…
6 files changed
+1
-1
+1
-1
+12
-5
+15
-22
+15
-22
+2
+1
-1
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -838,11 +838,11 @@ | ||
| 838 | 838 | #if defined(_WIN32) |
| 839 | 839 | fflush(stdout); |
| 840 | 840 | _setmode(_fileno(stdout), _O_TEXT); |
| 841 | 841 | #endif |
| 842 | 842 | }else{ |
| 843 | - file_mkfolder(zFilename, 1); | |
| 843 | + file_mkfolder(zFilename, 1, 0); | |
| 844 | 844 | out = fossil_fopen(zFilename, "wb"); |
| 845 | 845 | if( out==0 ){ |
| 846 | 846 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 847 | 847 | zFilename); |
| 848 | 848 | return 0; |
| 849 | 849 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -838,11 +838,11 @@ | |
| 838 | #if defined(_WIN32) |
| 839 | fflush(stdout); |
| 840 | _setmode(_fileno(stdout), _O_TEXT); |
| 841 | #endif |
| 842 | }else{ |
| 843 | file_mkfolder(zFilename, 1); |
| 844 | out = fossil_fopen(zFilename, "wb"); |
| 845 | if( out==0 ){ |
| 846 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 847 | zFilename); |
| 848 | return 0; |
| 849 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -838,11 +838,11 @@ | |
| 838 | #if defined(_WIN32) |
| 839 | fflush(stdout); |
| 840 | _setmode(_fileno(stdout), _O_TEXT); |
| 841 | #endif |
| 842 | }else{ |
| 843 | file_mkfolder(zFilename, 1, 0); |
| 844 | out = fossil_fopen(zFilename, "wb"); |
| 845 | if( out==0 ){ |
| 846 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 847 | zFilename); |
| 848 | return 0; |
| 849 |
+1
-1
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -838,11 +838,11 @@ | ||
| 838 | 838 | #if defined(_WIN32) |
| 839 | 839 | fflush(stdout); |
| 840 | 840 | _setmode(_fileno(stdout), _O_TEXT); |
| 841 | 841 | #endif |
| 842 | 842 | }else{ |
| 843 | - file_mkfolder(zFilename, 1); | |
| 843 | + file_mkfolder(zFilename, 1, 0); | |
| 844 | 844 | out = fossil_fopen(zFilename, "wb"); |
| 845 | 845 | if( out==0 ){ |
| 846 | 846 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 847 | 847 | zFilename); |
| 848 | 848 | return 0; |
| 849 | 849 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -838,11 +838,11 @@ | |
| 838 | #if defined(_WIN32) |
| 839 | fflush(stdout); |
| 840 | _setmode(_fileno(stdout), _O_TEXT); |
| 841 | #endif |
| 842 | }else{ |
| 843 | file_mkfolder(zFilename, 1); |
| 844 | out = fossil_fopen(zFilename, "wb"); |
| 845 | if( out==0 ){ |
| 846 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 847 | zFilename); |
| 848 | return 0; |
| 849 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -838,11 +838,11 @@ | |
| 838 | #if defined(_WIN32) |
| 839 | fflush(stdout); |
| 840 | _setmode(_fileno(stdout), _O_TEXT); |
| 841 | #endif |
| 842 | }else{ |
| 843 | file_mkfolder(zFilename, 1, 0); |
| 844 | out = fossil_fopen(zFilename, "wb"); |
| 845 | if( out==0 ){ |
| 846 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 847 | zFilename); |
| 848 | return 0; |
| 849 |
+12
-5
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -386,11 +386,11 @@ | ||
| 386 | 386 | FILE *in, *out; |
| 387 | 387 | int got; |
| 388 | 388 | char zBuf[8192]; |
| 389 | 389 | in = fossil_fopen(zFrom, "rb"); |
| 390 | 390 | if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); |
| 391 | - file_mkfolder(zTo, 0); | |
| 391 | + file_mkfolder(zTo, 0, 0); | |
| 392 | 392 | out = fossil_fopen(zTo, "wb"); |
| 393 | 393 | if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); |
| 394 | 394 | while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ |
| 395 | 395 | fwrite(zBuf, 1, got, out); |
| 396 | 396 | } |
| @@ -530,13 +530,16 @@ | ||
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /* |
| 533 | 533 | ** Create the tree of directories in which zFilename belongs, if that sequence |
| 534 | 534 | ** of directories does not already exist. |
| 535 | +** | |
| 536 | +** On success, return zero. On error, return errorReturn if positive, otherwise | |
| 537 | +** print an error message and abort. | |
| 535 | 538 | */ |
| 536 | -void file_mkfolder(const char *zFilename, int forceFlag){ | |
| 537 | - int i, nName; | |
| 539 | +int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){ | |
| 540 | + int i, nName, rc = 0; | |
| 538 | 541 | char *zName; |
| 539 | 542 | |
| 540 | 543 | nName = strlen(zFilename); |
| 541 | 544 | zName = mprintf("%s", zFilename); |
| 542 | 545 | nName = file_simplify_name(zName, nName, 0); |
| @@ -550,20 +553,24 @@ | ||
| 550 | 553 | ** C: in this example. |
| 551 | 554 | */ |
| 552 | 555 | if( !(i==2 && zName[1]==':') ){ |
| 553 | 556 | #endif |
| 554 | 557 | if( file_mkdir(zName, forceFlag) && file_isdir(zName)!=1 ){ |
| 555 | - fossil_fatal_recursive("unable to create directory %s", zName); | |
| 556 | - return; | |
| 558 | + if (errorReturn <= 0) { | |
| 559 | + fossil_fatal_recursive("unable to create directory %s", zName); | |
| 560 | + } | |
| 561 | + rc = errorReturn; | |
| 562 | + break; | |
| 557 | 563 | } |
| 558 | 564 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 559 | 565 | } |
| 560 | 566 | #endif |
| 561 | 567 | zName[i] = '/'; |
| 562 | 568 | } |
| 563 | 569 | } |
| 564 | 570 | free(zName); |
| 571 | + return rc; | |
| 565 | 572 | } |
| 566 | 573 | |
| 567 | 574 | /* |
| 568 | 575 | ** Removes the directory named in the argument, if it exists. The directory |
| 569 | 576 | ** must be empty and cannot be the current directory or the root directory. |
| 570 | 577 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -386,11 +386,11 @@ | |
| 386 | FILE *in, *out; |
| 387 | int got; |
| 388 | char zBuf[8192]; |
| 389 | in = fossil_fopen(zFrom, "rb"); |
| 390 | if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); |
| 391 | file_mkfolder(zTo, 0); |
| 392 | out = fossil_fopen(zTo, "wb"); |
| 393 | if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); |
| 394 | while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ |
| 395 | fwrite(zBuf, 1, got, out); |
| 396 | } |
| @@ -530,13 +530,16 @@ | |
| 530 | } |
| 531 | |
| 532 | /* |
| 533 | ** Create the tree of directories in which zFilename belongs, if that sequence |
| 534 | ** of directories does not already exist. |
| 535 | */ |
| 536 | void file_mkfolder(const char *zFilename, int forceFlag){ |
| 537 | int i, nName; |
| 538 | char *zName; |
| 539 | |
| 540 | nName = strlen(zFilename); |
| 541 | zName = mprintf("%s", zFilename); |
| 542 | nName = file_simplify_name(zName, nName, 0); |
| @@ -550,20 +553,24 @@ | |
| 550 | ** C: in this example. |
| 551 | */ |
| 552 | if( !(i==2 && zName[1]==':') ){ |
| 553 | #endif |
| 554 | if( file_mkdir(zName, forceFlag) && file_isdir(zName)!=1 ){ |
| 555 | fossil_fatal_recursive("unable to create directory %s", zName); |
| 556 | return; |
| 557 | } |
| 558 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 559 | } |
| 560 | #endif |
| 561 | zName[i] = '/'; |
| 562 | } |
| 563 | } |
| 564 | free(zName); |
| 565 | } |
| 566 | |
| 567 | /* |
| 568 | ** Removes the directory named in the argument, if it exists. The directory |
| 569 | ** must be empty and cannot be the current directory or the root directory. |
| 570 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -386,11 +386,11 @@ | |
| 386 | FILE *in, *out; |
| 387 | int got; |
| 388 | char zBuf[8192]; |
| 389 | in = fossil_fopen(zFrom, "rb"); |
| 390 | if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); |
| 391 | file_mkfolder(zTo, 0, 0); |
| 392 | out = fossil_fopen(zTo, "wb"); |
| 393 | if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); |
| 394 | while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ |
| 395 | fwrite(zBuf, 1, got, out); |
| 396 | } |
| @@ -530,13 +530,16 @@ | |
| 530 | } |
| 531 | |
| 532 | /* |
| 533 | ** Create the tree of directories in which zFilename belongs, if that sequence |
| 534 | ** of directories does not already exist. |
| 535 | ** |
| 536 | ** On success, return zero. On error, return errorReturn if positive, otherwise |
| 537 | ** print an error message and abort. |
| 538 | */ |
| 539 | int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){ |
| 540 | int i, nName, rc = 0; |
| 541 | char *zName; |
| 542 | |
| 543 | nName = strlen(zFilename); |
| 544 | zName = mprintf("%s", zFilename); |
| 545 | nName = file_simplify_name(zName, nName, 0); |
| @@ -550,20 +553,24 @@ | |
| 553 | ** C: in this example. |
| 554 | */ |
| 555 | if( !(i==2 && zName[1]==':') ){ |
| 556 | #endif |
| 557 | if( file_mkdir(zName, forceFlag) && file_isdir(zName)!=1 ){ |
| 558 | if (errorReturn <= 0) { |
| 559 | fossil_fatal_recursive("unable to create directory %s", zName); |
| 560 | } |
| 561 | rc = errorReturn; |
| 562 | break; |
| 563 | } |
| 564 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 565 | } |
| 566 | #endif |
| 567 | zName[i] = '/'; |
| 568 | } |
| 569 | } |
| 570 | free(zName); |
| 571 | return rc; |
| 572 | } |
| 573 | |
| 574 | /* |
| 575 | ** Removes the directory named in the argument, if it exists. The directory |
| 576 | ** must be empty and cannot be the current directory or the root directory. |
| 577 |
+15
-22
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -586,43 +586,33 @@ | ||
| 586 | 586 | db_end_transaction(0); |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /* |
| 591 | -** Make sure empty directories are created | |
| 591 | +** Create empty directories specified by the empty-dirs setting. | |
| 592 | 592 | */ |
| 593 | 593 | void ensure_empty_dirs_created(void){ |
| 594 | - /* Make empty directories? */ | |
| 595 | 594 | char *zEmptyDirs = db_get("empty-dirs", 0); |
| 596 | 595 | if( zEmptyDirs!=0 ){ |
| 596 | + int i; | |
| 597 | 597 | char *bc; |
| 598 | 598 | Blob dirName; |
| 599 | 599 | Blob dirsList; |
| 600 | 600 | |
| 601 | - blob_zero(&dirsList); | |
| 602 | - blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs)); | |
| 603 | - /* Replace commas by spaces */ | |
| 604 | - bc = blob_str(&dirsList); | |
| 605 | - while( (*bc)!='\0' ){ | |
| 606 | - if( (*bc)==',' ) { *bc = ' '; } | |
| 607 | - ++bc; | |
| 608 | - } | |
| 609 | - /* Make directories */ | |
| 610 | - blob_zero(&dirName); | |
| 601 | + zEmptyDirs = fossil_strdup(zEmptyDirs); | |
| 602 | + for(i=0; zEmptyDirs[i]; i++){ | |
| 603 | + if( zEmptyDirs[i]==',' ) zEmptyDirs[i] = ' '; | |
| 604 | + } | |
| 605 | + blob_init(&dirsList, zEmptyDirs, -1); | |
| 611 | 606 | while( blob_token(&dirsList, &dirName) ){ |
| 612 | 607 | const char *zDir = blob_str(&dirName); |
| 613 | - /* Make full pathname of the directory */ | |
| 614 | - Blob path; | |
| 615 | - const char *zPath; | |
| 616 | - | |
| 617 | - blob_zero(&path); | |
| 618 | - blob_appendf(&path, "%s/%s", g.zLocalRoot, zDir); | |
| 619 | - zPath = blob_str(&path); | |
| 620 | - /* Handle various cases of existence of the directory */ | |
| 608 | + const char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir); | |
| 621 | 609 | switch( file_wd_isdir(zPath) ){ |
| 622 | 610 | case 0: { /* doesn't exist */ |
| 623 | - if( file_mkdir(zPath, 0)!=0 ) { | |
| 611 | + fossil_free(zPath); | |
| 612 | + zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir); | |
| 613 | + if( file_mkfolder(zPath, 0, 1)!=0 ) { | |
| 624 | 614 | fossil_warning("couldn't create directory %s as " |
| 625 | 615 | "required by empty-dirs setting", zDir); |
| 626 | 616 | } |
| 627 | 617 | break; |
| 628 | 618 | } |
| @@ -633,12 +623,15 @@ | ||
| 633 | 623 | case 2: { /* exists, but isn't a directory */ |
| 634 | 624 | fossil_warning("file %s found, but a directory is required " |
| 635 | 625 | "by empty-dirs setting", zDir); |
| 636 | 626 | } |
| 637 | 627 | } |
| 638 | - blob_reset(&path); | |
| 628 | + fossil_free(zPath); | |
| 629 | + blob_reset(&dirName); | |
| 639 | 630 | } |
| 631 | + blob_reset(&dirsList); | |
| 632 | + fossil_free(zEmptyDirs); | |
| 640 | 633 | } |
| 641 | 634 | } |
| 642 | 635 | |
| 643 | 636 | |
| 644 | 637 | /* |
| 645 | 638 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -586,43 +586,33 @@ | |
| 586 | db_end_transaction(0); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | /* |
| 591 | ** Make sure empty directories are created |
| 592 | */ |
| 593 | void ensure_empty_dirs_created(void){ |
| 594 | /* Make empty directories? */ |
| 595 | char *zEmptyDirs = db_get("empty-dirs", 0); |
| 596 | if( zEmptyDirs!=0 ){ |
| 597 | char *bc; |
| 598 | Blob dirName; |
| 599 | Blob dirsList; |
| 600 | |
| 601 | blob_zero(&dirsList); |
| 602 | blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs)); |
| 603 | /* Replace commas by spaces */ |
| 604 | bc = blob_str(&dirsList); |
| 605 | while( (*bc)!='\0' ){ |
| 606 | if( (*bc)==',' ) { *bc = ' '; } |
| 607 | ++bc; |
| 608 | } |
| 609 | /* Make directories */ |
| 610 | blob_zero(&dirName); |
| 611 | while( blob_token(&dirsList, &dirName) ){ |
| 612 | const char *zDir = blob_str(&dirName); |
| 613 | /* Make full pathname of the directory */ |
| 614 | Blob path; |
| 615 | const char *zPath; |
| 616 | |
| 617 | blob_zero(&path); |
| 618 | blob_appendf(&path, "%s/%s", g.zLocalRoot, zDir); |
| 619 | zPath = blob_str(&path); |
| 620 | /* Handle various cases of existence of the directory */ |
| 621 | switch( file_wd_isdir(zPath) ){ |
| 622 | case 0: { /* doesn't exist */ |
| 623 | if( file_mkdir(zPath, 0)!=0 ) { |
| 624 | fossil_warning("couldn't create directory %s as " |
| 625 | "required by empty-dirs setting", zDir); |
| 626 | } |
| 627 | break; |
| 628 | } |
| @@ -633,12 +623,15 @@ | |
| 633 | case 2: { /* exists, but isn't a directory */ |
| 634 | fossil_warning("file %s found, but a directory is required " |
| 635 | "by empty-dirs setting", zDir); |
| 636 | } |
| 637 | } |
| 638 | blob_reset(&path); |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | |
| 644 | /* |
| 645 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -586,43 +586,33 @@ | |
| 586 | db_end_transaction(0); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | /* |
| 591 | ** Create empty directories specified by the empty-dirs setting. |
| 592 | */ |
| 593 | void ensure_empty_dirs_created(void){ |
| 594 | char *zEmptyDirs = db_get("empty-dirs", 0); |
| 595 | if( zEmptyDirs!=0 ){ |
| 596 | int i; |
| 597 | char *bc; |
| 598 | Blob dirName; |
| 599 | Blob dirsList; |
| 600 | |
| 601 | zEmptyDirs = fossil_strdup(zEmptyDirs); |
| 602 | for(i=0; zEmptyDirs[i]; i++){ |
| 603 | if( zEmptyDirs[i]==',' ) zEmptyDirs[i] = ' '; |
| 604 | } |
| 605 | blob_init(&dirsList, zEmptyDirs, -1); |
| 606 | while( blob_token(&dirsList, &dirName) ){ |
| 607 | const char *zDir = blob_str(&dirName); |
| 608 | const char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir); |
| 609 | switch( file_wd_isdir(zPath) ){ |
| 610 | case 0: { /* doesn't exist */ |
| 611 | fossil_free(zPath); |
| 612 | zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir); |
| 613 | if( file_mkfolder(zPath, 0, 1)!=0 ) { |
| 614 | fossil_warning("couldn't create directory %s as " |
| 615 | "required by empty-dirs setting", zDir); |
| 616 | } |
| 617 | break; |
| 618 | } |
| @@ -633,12 +623,15 @@ | |
| 623 | case 2: { /* exists, but isn't a directory */ |
| 624 | fossil_warning("file %s found, but a directory is required " |
| 625 | "by empty-dirs setting", zDir); |
| 626 | } |
| 627 | } |
| 628 | fossil_free(zPath); |
| 629 | blob_reset(&dirName); |
| 630 | } |
| 631 | blob_reset(&dirsList); |
| 632 | fossil_free(zEmptyDirs); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | |
| 637 | /* |
| 638 |
+15
-22
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -586,43 +586,33 @@ | ||
| 586 | 586 | db_end_transaction(0); |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /* |
| 591 | -** Make sure empty directories are created | |
| 591 | +** Create empty directories specified by the empty-dirs setting. | |
| 592 | 592 | */ |
| 593 | 593 | void ensure_empty_dirs_created(void){ |
| 594 | - /* Make empty directories? */ | |
| 595 | 594 | char *zEmptyDirs = db_get("empty-dirs", 0); |
| 596 | 595 | if( zEmptyDirs!=0 ){ |
| 596 | + int i; | |
| 597 | 597 | char *bc; |
| 598 | 598 | Blob dirName; |
| 599 | 599 | Blob dirsList; |
| 600 | 600 | |
| 601 | - blob_zero(&dirsList); | |
| 602 | - blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs)); | |
| 603 | - /* Replace commas by spaces */ | |
| 604 | - bc = blob_str(&dirsList); | |
| 605 | - while( (*bc)!='\0' ){ | |
| 606 | - if( (*bc)==',' ) { *bc = ' '; } | |
| 607 | - ++bc; | |
| 608 | - } | |
| 609 | - /* Make directories */ | |
| 610 | - blob_zero(&dirName); | |
| 601 | + zEmptyDirs = fossil_strdup(zEmptyDirs); | |
| 602 | + for(i=0; zEmptyDirs[i]; i++){ | |
| 603 | + if( zEmptyDirs[i]==',' ) zEmptyDirs[i] = ' '; | |
| 604 | + } | |
| 605 | + blob_init(&dirsList, zEmptyDirs, -1); | |
| 611 | 606 | while( blob_token(&dirsList, &dirName) ){ |
| 612 | 607 | const char *zDir = blob_str(&dirName); |
| 613 | - /* Make full pathname of the directory */ | |
| 614 | - Blob path; | |
| 615 | - const char *zPath; | |
| 616 | - | |
| 617 | - blob_zero(&path); | |
| 618 | - blob_appendf(&path, "%s/%s", g.zLocalRoot, zDir); | |
| 619 | - zPath = blob_str(&path); | |
| 620 | - /* Handle various cases of existence of the directory */ | |
| 608 | + const char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir); | |
| 621 | 609 | switch( file_wd_isdir(zPath) ){ |
| 622 | 610 | case 0: { /* doesn't exist */ |
| 623 | - if( file_mkdir(zPath, 0)!=0 ) { | |
| 611 | + fossil_free(zPath); | |
| 612 | + zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir); | |
| 613 | + if( file_mkfolder(zPath, 0, 1)!=0 ) { | |
| 624 | 614 | fossil_warning("couldn't create directory %s as " |
| 625 | 615 | "required by empty-dirs setting", zDir); |
| 626 | 616 | } |
| 627 | 617 | break; |
| 628 | 618 | } |
| @@ -633,12 +623,15 @@ | ||
| 633 | 623 | case 2: { /* exists, but isn't a directory */ |
| 634 | 624 | fossil_warning("file %s found, but a directory is required " |
| 635 | 625 | "by empty-dirs setting", zDir); |
| 636 | 626 | } |
| 637 | 627 | } |
| 638 | - blob_reset(&path); | |
| 628 | + fossil_free(zPath); | |
| 629 | + blob_reset(&dirName); | |
| 639 | 630 | } |
| 631 | + blob_reset(&dirsList); | |
| 632 | + fossil_free(zEmptyDirs); | |
| 640 | 633 | } |
| 641 | 634 | } |
| 642 | 635 | |
| 643 | 636 | |
| 644 | 637 | /* |
| 645 | 638 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -586,43 +586,33 @@ | |
| 586 | db_end_transaction(0); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | /* |
| 591 | ** Make sure empty directories are created |
| 592 | */ |
| 593 | void ensure_empty_dirs_created(void){ |
| 594 | /* Make empty directories? */ |
| 595 | char *zEmptyDirs = db_get("empty-dirs", 0); |
| 596 | if( zEmptyDirs!=0 ){ |
| 597 | char *bc; |
| 598 | Blob dirName; |
| 599 | Blob dirsList; |
| 600 | |
| 601 | blob_zero(&dirsList); |
| 602 | blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs)); |
| 603 | /* Replace commas by spaces */ |
| 604 | bc = blob_str(&dirsList); |
| 605 | while( (*bc)!='\0' ){ |
| 606 | if( (*bc)==',' ) { *bc = ' '; } |
| 607 | ++bc; |
| 608 | } |
| 609 | /* Make directories */ |
| 610 | blob_zero(&dirName); |
| 611 | while( blob_token(&dirsList, &dirName) ){ |
| 612 | const char *zDir = blob_str(&dirName); |
| 613 | /* Make full pathname of the directory */ |
| 614 | Blob path; |
| 615 | const char *zPath; |
| 616 | |
| 617 | blob_zero(&path); |
| 618 | blob_appendf(&path, "%s/%s", g.zLocalRoot, zDir); |
| 619 | zPath = blob_str(&path); |
| 620 | /* Handle various cases of existence of the directory */ |
| 621 | switch( file_wd_isdir(zPath) ){ |
| 622 | case 0: { /* doesn't exist */ |
| 623 | if( file_mkdir(zPath, 0)!=0 ) { |
| 624 | fossil_warning("couldn't create directory %s as " |
| 625 | "required by empty-dirs setting", zDir); |
| 626 | } |
| 627 | break; |
| 628 | } |
| @@ -633,12 +623,15 @@ | |
| 633 | case 2: { /* exists, but isn't a directory */ |
| 634 | fossil_warning("file %s found, but a directory is required " |
| 635 | "by empty-dirs setting", zDir); |
| 636 | } |
| 637 | } |
| 638 | blob_reset(&path); |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | |
| 644 | /* |
| 645 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -586,43 +586,33 @@ | |
| 586 | db_end_transaction(0); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | /* |
| 591 | ** Create empty directories specified by the empty-dirs setting. |
| 592 | */ |
| 593 | void ensure_empty_dirs_created(void){ |
| 594 | char *zEmptyDirs = db_get("empty-dirs", 0); |
| 595 | if( zEmptyDirs!=0 ){ |
| 596 | int i; |
| 597 | char *bc; |
| 598 | Blob dirName; |
| 599 | Blob dirsList; |
| 600 | |
| 601 | zEmptyDirs = fossil_strdup(zEmptyDirs); |
| 602 | for(i=0; zEmptyDirs[i]; i++){ |
| 603 | if( zEmptyDirs[i]==',' ) zEmptyDirs[i] = ' '; |
| 604 | } |
| 605 | blob_init(&dirsList, zEmptyDirs, -1); |
| 606 | while( blob_token(&dirsList, &dirName) ){ |
| 607 | const char *zDir = blob_str(&dirName); |
| 608 | const char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir); |
| 609 | switch( file_wd_isdir(zPath) ){ |
| 610 | case 0: { /* doesn't exist */ |
| 611 | fossil_free(zPath); |
| 612 | zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir); |
| 613 | if( file_mkfolder(zPath, 0, 1)!=0 ) { |
| 614 | fossil_warning("couldn't create directory %s as " |
| 615 | "required by empty-dirs setting", zDir); |
| 616 | } |
| 617 | break; |
| 618 | } |
| @@ -633,12 +623,15 @@ | |
| 623 | case 2: { /* exists, but isn't a directory */ |
| 624 | fossil_warning("file %s found, but a directory is required " |
| 625 | "by empty-dirs setting", zDir); |
| 626 | } |
| 627 | } |
| 628 | fossil_free(zPath); |
| 629 | blob_reset(&dirName); |
| 630 | } |
| 631 | blob_reset(&dirsList); |
| 632 | fossil_free(zEmptyDirs); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | |
| 637 | /* |
| 638 |
+2
| --- www/changes.wiki | ||
| +++ www/changes.wiki | ||
| @@ -40,10 +40,12 @@ | ||
| 40 | 40 | symlink. Additionally show the UUID for files whose types have changed |
| 41 | 41 | without changing contents or symlink target. |
| 42 | 42 | * Have [/help?cmd=changes|fossil changes] and |
| 43 | 43 | [/help?cmd=status|fossil status] report when executable or symlink status |
| 44 | 44 | changes on otherwise unmodified files. |
| 45 | + * Create parent directories of [/help?cmd=settings|empty-dirs] if they don't | |
| 46 | + already exist. | |
| 45 | 47 | |
| 46 | 48 | <h2>Changes for Version 1.32 (2015-03-14)</h2> |
| 47 | 49 | * When creating a new repository using [/help?cmd=init|fossil init], ensure |
| 48 | 50 | that the new repository is fully compatible with historical versions of |
| 49 | 51 | Fossil by having a valid manifest as RID 1. |
| 50 | 52 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -40,10 +40,12 @@ | |
| 40 | symlink. Additionally show the UUID for files whose types have changed |
| 41 | without changing contents or symlink target. |
| 42 | * Have [/help?cmd=changes|fossil changes] and |
| 43 | [/help?cmd=status|fossil status] report when executable or symlink status |
| 44 | changes on otherwise unmodified files. |
| 45 | |
| 46 | <h2>Changes for Version 1.32 (2015-03-14)</h2> |
| 47 | * When creating a new repository using [/help?cmd=init|fossil init], ensure |
| 48 | that the new repository is fully compatible with historical versions of |
| 49 | Fossil by having a valid manifest as RID 1. |
| 50 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -40,10 +40,12 @@ | |
| 40 | symlink. Additionally show the UUID for files whose types have changed |
| 41 | without changing contents or symlink target. |
| 42 | * Have [/help?cmd=changes|fossil changes] and |
| 43 | [/help?cmd=status|fossil status] report when executable or symlink status |
| 44 | changes on otherwise unmodified files. |
| 45 | * Create parent directories of [/help?cmd=settings|empty-dirs] if they don't |
| 46 | already exist. |
| 47 | |
| 48 | <h2>Changes for Version 1.32 (2015-03-14)</h2> |
| 49 | * When creating a new repository using [/help?cmd=init|fossil init], ensure |
| 50 | that the new repository is fully compatible with historical versions of |
| 51 | Fossil by having a valid manifest as RID 1. |
| 52 |