| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2228f44 commit e8b1e2c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,6 +66,7 @@ const { | |||
| 66 | 66 | const { opendir } = require('internal/fs/dir'); | |
| 67 | 67 | const { | |
| 68 | 68 | parseFileMode, | |
| 69 | + validateAbortSignal, | ||
| 69 | 70 | validateBoolean, | |
| 70 | 71 | validateBuffer, | |
| 71 | 72 | validateInteger, | |
@@ -668,14 +669,17 @@ async function writeFile(path, data, options) { | |||
| 668 | 669 | data = Buffer.from(data, options.encoding || 'utf8'); | |
| 669 | 670 | } | |
| 670 | 671 | ||
| 672 | + validateAbortSignal(options.signal); | ||
| 671 | 673 | if (path instanceof FileHandle) | |
| 672 | 674 | return writeFileHandle(path, data, options.signal); | |
| 673 | 675 | ||
| 674 | - const fd = await open(path, flag, options.mode); | ||
| 675 | 676 | if (options.signal?.aborted) { | |
| 676 | 677 | throw lazyDOMException('The operation was aborted', 'AbortError'); | |
| 677 | 678 | } | |
| 678 | - return PromisePrototypeFinally(writeFileHandle(fd, data), fd.close); | ||
| 679 | + | ||
| 680 | + const fd = await open(path, flag, options.mode); | ||
| 681 | + const { signal } = options; | ||
| 682 | + return PromisePrototypeFinally(writeFileHandle(fd, data, signal), fd.close); | ||
| 679 | 683 | } | |
| 680 | 684 | ||
| 681 | 685 | async function appendFile(path, data, options) { | |
@@ -692,6 +696,10 @@ async function readFile(path, options) { | |||
| 692 | 696 | if (path instanceof FileHandle) | |
| 693 | 697 | return readFileHandle(path, options); | |
| 694 | 698 | ||
| 699 | + if (options.signal?.aborted) { | ||
| 700 | + throw lazyDOMException('The operation was aborted', 'AbortError'); | ||
| 701 | + } | ||
| 702 | + | ||
| 695 | 703 | const fd = await open(path, flag, 0o666); | |
| 696 | 704 | return PromisePrototypeFinally(readFileHandle(fd, options), fd.close); | |
| 697 | 705 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments