GeezerVison is showing github.com — fs: remove ability to call truncate with fd · nodejs/node@fabf938
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/deprecations.md +4-1Lines changed: 4 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1832,12 +1832,15 @@ and replaced with an identical, public `path.toNamespacedPath()` method. | 1832 | 1832 |
| 1833 | 1833 | <!-- YAML | 1834 | 1834 | changes: | | 1835 | + - version: REPLACEME | | 1836 | + pr-url: https://github.com/nodejs/node/pull/57567 | | 1837 | + description: End-of-Life. | 1835 | 1838 | - version: v9.0.0 | 1836 | 1839 | pr-url: https://github.com/nodejs/node/pull/15990 | 1837 | 1840 | description: Runtime deprecation. | 1838 | 1841 | --> | 1839 | 1842 |
| 1840 | | -Type: Runtime | | 1843 | +Type: End-of-Life | 1841 | 1844 |
| 1842 | 1845 | `fs.truncate()` `fs.truncateSync()` usage with a file descriptor is | 1843 | 1846 | deprecated. Please use `fs.ftruncate()` or `fs.ftruncateSync()` to work with | |
Collapse file Copy file name to clipboardExpand all lines: lib/fs.js -20Lines changed: 0 additions & 20 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -153,7 +153,6 @@ const { | 153 | 153 |
| 154 | 154 | const permission = require('internal/process/permission'); | 155 | 155 |
| 156 | | -let truncateWarn = true; | 157 | 156 | let fs; | 158 | 157 |
| 159 | 158 | // Lazy loaded | @@ -171,16 +170,6 @@ let ReadFileContext; | 171 | 170 | let FileReadStream; | 172 | 171 | let FileWriteStream; | 173 | 172 |
| 174 | | -function showTruncateDeprecation() { | 175 | | - if (truncateWarn) { | 176 | | - process.emitWarning( | 177 | | - 'Using fs.truncate with a file descriptor is deprecated. Please use ' + | 178 | | - 'fs.ftruncate with a file descriptor instead.', | 179 | | - 'DeprecationWarning', 'DEP0081'); | 180 | | - truncateWarn = false; | 181 | | - } | 182 | | -} | 183 | | - | 184 | 173 | // Ensure that callbacks run in the global context. Only use this function | 185 | 174 | // for callbacks that are passed to the binding layer, callbacks that are | 186 | 175 | // invoked from JS already run in the proper scope. | @@ -1035,10 +1024,6 @@ function renameSync(oldPath, newPath) { | 1035 | 1024 | * @returns {void} | 1036 | 1025 | */ | 1037 | 1026 | function truncate(path, len, callback) { | 1038 | | - if (typeof path === 'number') { | 1039 | | - showTruncateDeprecation(); | 1040 | | - return fs.ftruncate(path, len, callback); | 1041 | | - } | 1042 | 1027 | if (typeof len === 'function') { | 1043 | 1028 | callback = len; | 1044 | 1029 | len = 0; | @@ -1068,11 +1053,6 @@ function truncate(path, len, callback) { | 1068 | 1053 | * @returns {void} | 1069 | 1054 | */ | 1070 | 1055 | function truncateSync(path, len) { | 1071 | | - if (typeof path === 'number') { | 1072 | | - // legacy | 1073 | | - showTruncateDeprecation(); | 1074 | | - return fs.ftruncateSync(path, len); | 1075 | | - } | 1076 | 1056 | if (len === undefined) { | 1077 | 1057 | len = 0; | 1078 | 1058 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-truncate-fd.js -27Lines changed: 0 additions & 27 deletions Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-truncate-sync.js +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,10 +12,7 @@ const filename = path.resolve(tmp, 'truncate-sync-file.txt'); | 12 | 12 |
| 13 | 13 | fs.writeFileSync(filename, 'hello world', 'utf8'); | 14 | 14 |
| 15 | | -const fd = fs.openSync(filename, 'r+'); | | 15 | +fs.truncateSync(filename, 5); | | 16 | +assert(fs.readFileSync(filename).equals(Buffer.from('hello'))); | 16 | 17 |
| 17 | | -fs.truncateSync(fd, 5); | 18 | | -assert(fs.readFileSync(fd).equals(Buffer.from('hello'))); | 19 | | - | 20 | | -fs.closeSync(fd); | 21 | 18 | fs.unlinkSync(filename); |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-truncate.js -7Lines changed: 0 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,9 +33,6 @@ tmpdir.refresh(); | 33 | 33 |
| 34 | 34 | let stat; | 35 | 35 |
| 36 | | -const msg = 'Using fs.truncate with a file descriptor is deprecated.' + | 37 | | - ' Please use fs.ftruncate with a file descriptor instead.'; | 38 | | - | 39 | 36 | // Check truncateSync | 40 | 37 | fs.writeFileSync(filename, data); | 41 | 38 | stat = fs.statSync(filename); | @@ -64,10 +61,6 @@ fs.ftruncateSync(fd); | 64 | 61 | stat = fs.statSync(filename); | 65 | 62 | assert.strictEqual(stat.size, 0); | 66 | 63 |
| 67 | | -// truncateSync | 68 | | -common.expectWarning('DeprecationWarning', msg, 'DEP0081'); | 69 | | -fs.truncateSync(fd); | 70 | | - | 71 | 64 | fs.closeSync(fd); | 72 | 65 |
| 73 | 66 | // Async tests | |
|