Commit 2235e13
authored
[Storage] Require explicit recursive flag for mkdir (and tweak the semantics of writeFile and listFiles) (#2969)
## Summary
This PR changes the filesystem backends to require explicit `recursive:
true` when creating nested directories, matching standard filesystem
semantics.
Previously, `mkdir('/a/b/c')` would silently create all parent
directories. Now it throws if `/a/b` doesn't exist, unless you pass
`recursive: true`.
Similarly, `writeFile('/a/b/file.txt')` now throws if `/a/b` doesn't
exist, instead of creating it.
**Changes:**
- `mkdir(path, recursive?)` - only creates parent dirs when
`recursive=true`
- `writeFile(path, data)` - throws if parent directory doesn't exist
- `listFiles(path)` - returns `[]` for non-existent paths (consistent
with FSHelpers)
- `mkdir('/')` - now a no-op instead of throwing
**Updated interfaces:**
- `WritableFilesystemBackend.mkdir(path, recursive?: boolean)`
- `AsyncWritableFilesystem.mkdir(path, options?: { recursive?: boolean
})`
## Test plan
- [x] Added tests for `mkdir` throwing without recursive flag
- [x] Added tests for `mkdir` with recursive flag creating nested dirs
- [x] Added tests for `writeFile` throwing when parent doesn't exist
- [x] Added tests for `listFiles` returning `[]` for non-existent paths
- [x] Updated Blueprint Editor to use `{ recursive: true }` when
creating parent dirs1 parent 1344ee7 commit 2235e13
File tree
3 files changed
+91
-22
lines changed- packages/playground
- storage/src/lib
- website/src/components/blueprint-editor
3 files changed
+91
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
504 | | - | |
505 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
506 | 512 | | |
507 | 513 | | |
508 | 514 | | |
| |||
513 | 519 | | |
514 | 520 | | |
515 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
516 | 528 | | |
517 | 529 | | |
518 | 530 | | |
| |||
525 | 537 | | |
526 | 538 | | |
527 | 539 | | |
528 | | - | |
| 540 | + | |
529 | 541 | | |
530 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
531 | 546 | | |
532 | | - | |
533 | | - | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
534 | 551 | | |
535 | 552 | | |
536 | 553 | | |
| |||
556 | 573 | | |
557 | 574 | | |
558 | 575 | | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
559 | 587 | | |
560 | 588 | | |
561 | 589 | | |
| |||
576 | 604 | | |
577 | 605 | | |
578 | 606 | | |
579 | | - | |
| 607 | + | |
580 | 608 | | |
581 | 609 | | |
582 | 610 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
596 | 599 | | |
597 | 600 | | |
598 | 601 | | |
| 602 | + | |
599 | 603 | | |
600 | 604 | | |
601 | | - | |
| 605 | + | |
602 | 606 | | |
603 | 607 | | |
604 | 608 | | |
605 | 609 | | |
606 | 610 | | |
607 | 611 | | |
608 | 612 | | |
609 | | - | |
| 613 | + | |
610 | 614 | | |
611 | 615 | | |
612 | | - | |
613 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
614 | 623 | | |
615 | 624 | | |
616 | 625 | | |
| |||
733 | 742 | | |
734 | 743 | | |
735 | 744 | | |
736 | | - | |
737 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
738 | 750 | | |
739 | 751 | | |
740 | 752 | | |
741 | 753 | | |
742 | 754 | | |
743 | 755 | | |
744 | | - | |
745 | | - | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
746 | 764 | | |
747 | 765 | | |
748 | 766 | | |
| |||
833 | 851 | | |
834 | 852 | | |
835 | 853 | | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
836 | 857 | | |
837 | 858 | | |
838 | 859 | | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
839 | 863 | | |
840 | | - | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
841 | 880 | | |
842 | 881 | | |
843 | 882 | | |
| 883 | + | |
| 884 | + | |
844 | 885 | | |
845 | 886 | | |
846 | 887 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
0 commit comments