| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7aa2e5d commit 0269413
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,6 +63,7 @@ const { | |||
| 63 | 63 | const { opendir } = require('internal/fs/dir'); | |
| 64 | 64 | const { | |
| 65 | 65 | parseFileMode, | |
| 66 | + validateAbortSignal, | ||
| 66 | 67 | validateBuffer, | |
| 67 | 68 | validateInteger, | |
| 68 | 69 | validateUint32 | |
@@ -646,14 +647,17 @@ async function writeFile(path, data, options) { | |||
| 646 | 647 | data = Buffer.from(data, options.encoding || 'utf8'); | |
| 647 | 648 | } | |
| 648 | 649 | ||
| 650 | + validateAbortSignal(options.signal); | ||
| 649 | 651 | if (path instanceof FileHandle) | |
| 650 | 652 | return writeFileHandle(path, data, options.signal); | |
| 651 | 653 | ||
| 652 | - const fd = await open(path, flag, options.mode); | ||
| 653 | 654 | if (options.signal?.aborted) { | |
| 654 | 655 | throw new lazyDOMException('The operation was aborted', 'AbortError'); | |
| 655 | 656 | } | |
| 656 | - return PromisePrototypeFinally(writeFileHandle(fd, data), fd.close); | ||
| 657 | + | ||
| 658 | + const fd = await open(path, flag, options.mode); | ||
| 659 | + const { signal } = options; | ||
| 660 | + return PromisePrototypeFinally(writeFileHandle(fd, data, signal), fd.close); | ||
| 657 | 661 | } | |
| 658 | 662 | ||
| 659 | 663 | async function appendFile(path, data, options) { | |
@@ -670,6 +674,10 @@ async function readFile(path, options) { | |||
| 670 | 674 | if (path instanceof FileHandle) | |
| 671 | 675 | return readFileHandle(path, options); | |
| 672 | 676 | ||
| 677 | + if (options.signal?.aborted) { | ||
| 678 | + throw lazyDOMException('The operation was aborted', 'AbortError'); | ||
| 679 | + } | ||
| 680 | + | ||
| 673 | 681 | const fd = await open(path, flag, 0o666); | |
| 674 | 682 | return PromisePrototypeFinally(readFileHandle(fd, options), fd.close); | |
| 675 | 683 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments