GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: remove ability to call truncate with fd · nodejs/node@fabf938

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • deprecations.md
  • lib
    • fs.js
  • test/parallel
    • test-fs-truncate-fd.js
    • test-fs-truncate-sync.js
    • test-fs-truncate.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/deprecations.md‎

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 numberDiff line numberDiff line change
@@ -1832,12 +1832,15 @@ and replaced with an identical, public `path.toNamespacedPath()` method.
18321832

18331833
<!-- YAML
18341834
changes:
1835+
- version: REPLACEME
1836+
pr-url: https://github.com/nodejs/node/pull/57567
1837+
description: End-of-Life.
18351838
- version: v9.0.0
18361839
pr-url: https://github.com/nodejs/node/pull/15990
18371840
description: Runtime deprecation.
18381841
-->
18391842

1840-
Type: Runtime
1843+
Type: End-of-Life
18411844

18421845
`fs.truncate()` `fs.truncateSync()` usage with a file descriptor is
18431846
deprecated. Please use `fs.ftruncate()` or `fs.ftruncateSync()` to work with
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
-20Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ const {
153153

154154
const permission = require('internal/process/permission');
155155

156-
let truncateWarn = true;
157156
let fs;
158157

159158
// Lazy loaded
@@ -171,16 +170,6 @@ let ReadFileContext;
171170
let FileReadStream;
172171
let FileWriteStream;
173172

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-
184173
// Ensure that callbacks run in the global context. Only use this function
185174
// for callbacks that are passed to the binding layer, callbacks that are
186175
// invoked from JS already run in the proper scope.
@@ -1035,10 +1024,6 @@ function renameSync(oldPath, newPath) {
10351024
* @returns {void}
10361025
*/
10371026
function truncate(path, len, callback) {
1038-
if (typeof path === 'number') {
1039-
showTruncateDeprecation();
1040-
return fs.ftruncate(path, len, callback);
1041-
}
10421027
if (typeof len === 'function') {
10431028
callback = len;
10441029
len = 0;
@@ -1068,11 +1053,6 @@ function truncate(path, len, callback) {
10681053
* @returns {void}
10691054
*/
10701055
function truncateSync(path, len) {
1071-
if (typeof path === 'number') {
1072-
// legacy
1073-
showTruncateDeprecation();
1074-
return fs.ftruncateSync(path, len);
1075-
}
10761056
if (len === undefined) {
10771057
len = 0;
10781058
}
Collapse file

‎test/parallel/test-fs-truncate-fd.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-truncate-fd.js
-27Lines changed: 0 additions & 27 deletions
This file was deleted.
Collapse file

‎test/parallel/test-fs-truncate-sync.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-truncate-sync.js
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ const filename = path.resolve(tmp, 'truncate-sync-file.txt');
1212

1313
fs.writeFileSync(filename, 'hello world', 'utf8');
1414

15-
const fd = fs.openSync(filename, 'r+');
15+
fs.truncateSync(filename, 5);
16+
assert(fs.readFileSync(filename).equals(Buffer.from('hello')));
1617

17-
fs.truncateSync(fd, 5);
18-
assert(fs.readFileSync(fd).equals(Buffer.from('hello')));
19-
20-
fs.closeSync(fd);
2118
fs.unlinkSync(filename);
Collapse file

‎test/parallel/test-fs-truncate.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-truncate.js
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ tmpdir.refresh();
3333

3434
let stat;
3535

36-
const msg = 'Using fs.truncate with a file descriptor is deprecated.' +
37-
' Please use fs.ftruncate with a file descriptor instead.';
38-
3936
// Check truncateSync
4037
fs.writeFileSync(filename, data);
4138
stat = fs.statSync(filename);
@@ -64,10 +61,6 @@ fs.ftruncateSync(fd);
6461
stat = fs.statSync(filename);
6562
assert.strictEqual(stat.size, 0);
6663

67-
// truncateSync
68-
common.expectWarning('DeprecationWarning', msg, 'DEP0081');
69-
fs.truncateSync(fd);
70-
7164
fs.closeSync(fd);
7265

7366
// Async tests

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.