Skip to content

doc: Change doc on fs.rename api w.r.t to windows behaviour - #22014

Closed
antsmartian wants to merge 1 commit into
nodejs:masterfrom
antsmartian:21957
Closed

doc: Change doc on fs.rename api w.r.t to windows behaviour#22014
antsmartian wants to merge 1 commit into
nodejs:masterfrom
antsmartian:21957

Conversation

@antsmartian

@antsmartian antsmartian commented Jul 28, 2018

Copy link
Copy Markdown
Contributor

Fixes : #21957

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Jul 28, 2018
@antsmartian
antsmartian force-pushed the 21957 branch 2 times, most recently from 7f360eb to a6d171b Compare July 28, 2018 09:57
Comment thread doc/api/fs.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the deletion of the last sentence intended?

Comment thread doc/api/fs.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter nit: this line needs to be wrapped to not exceed 80 characters.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described in ##21957 (comment) that is actually not always true. Unix systems will not raise an exception if the directory is empty. That is only the case for Windows. I did not check but that should hold true for all OS.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Is this true for all supported systems?

@daliadefelipee

Copy link
Copy Markdown

Hi @vsemozhetbyt , actually I think the issue was that the result differs from system to system so I think It wold be nice if the docs inform you about each case, although I don't know if it's possible.

@antsmartian

antsmartian commented Jul 30, 2018

Copy link
Copy Markdown
Contributor Author

I thought of writing like:

Asynchronously rename file or directory at oldPath to the pathname provided
as newPath. In the case that newPath already exists, it will
be overwritten. fs.rename can throw the below error:

  • On Linux when renaming directory exists and is NOT empty, it throws a
    ENOTEMPTY error.
  • On Unix when renaming directory exists and is NOT empty, it throws a
    ENOENT error.
  • On Windows regardless of renaming directory is empty, it throws a
    EPERM error.

No arguments other than a possible exception (like mentioned above) are given to
the completion callback.

Thoughts? cc @vsemozhetbyt @BridgeAR

@antsmartian

Copy link
Copy Markdown
Contributor Author

ping @vsemozhetbyt :)

Comment thread doc/api/fs.md
given to the completion callback.
be overwritten. `fs.rename` can throw the below error:

- On **Linux** when renaming directory exists and is NOT empty, it throws a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Not sure if renaming is a right form here and below. Let's see what native speakers think.
  2. a `ENOTEMPTY` - > an `ENOTEMPTY` (as well as below).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not clear or grammatical, call it after the name of the arg: "if newPath exists"... and likewise in other places.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Unfortunately, I have not enough knowledge in this realm to fully review. Maybe @nodejs/fs can assess?

@joyeecheung

Copy link
Copy Markdown
Member

To be honest I feel like this inconsistency is a bug that we need to fix rather than document..

@jasnell

jasnell commented Sep 10, 2018

Copy link
Copy Markdown
Member

What's the status on this one?

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Sep 10, 2018
@antsmartian

Copy link
Copy Markdown
Contributor Author

@jasnell I guess doc is fine (until bug fix), but @joyeecheung feels we need to fix. So need input from them.

@antsmartian

Copy link
Copy Markdown
Contributor Author

@joyeecheung If there is any plan to fix the actual issue? (Since we discussed documentation wouldn't help much here)

@thefourtheye

Copy link
Copy Markdown
Contributor

If I am not wrong, this has to be addressed at libuv level. I'll take a look at it and update within this week.

Comment thread doc/api/fs.md
- On **Windows** regardless of renaming directory is empty, it throws a
`EPERM` error.

No arguments other than a possible exception (as mentioned above) are given to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just repeats line 2698 in a more complex written form, and it adds confusion. It says an exception is given to the completion callback, but it is an error that is given. Also, more errors than the few documented can occur, and the sentence reads to me as saying that only the errors documented above can be passed. Better, I think, to remove the sentence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sam-github Make sense.

@cjihrig

cjihrig commented Nov 20, 2018

Copy link
Copy Markdown
Contributor

If I am not wrong, this has to be addressed at libuv level.

There was a PR in libuv/libuv#1941, but it didn't really gain any traction.

@thefourtheye

Copy link
Copy Markdown
Contributor

There was a PR in libuv/libuv#1941, but it didn't really gain any traction.

Awesome we already have some code then. Let's dust it up and reuse 😊

@fhinkel

fhinkel commented Oct 26, 2019

Copy link
Copy Markdown
Contributor

Looks like this can be closed. Please re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. stalled Issues and PRs that are stalled.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.rename doesn't work as documented