Uh oh!
There was an error while loading. Please reload this page.
repl: support hidden history file on Windows - #12207
Conversation
On Windows when REPL history file has the hidden attribute node will fail when trying to open it in 'w' mode. This changes the mode to 'r+'. The file is guaranteed to exists because of earlier open call with 'a+'.
| } | ||
| fs.open(historyPath, 'w', onhandle); | ||
| fs.open(historyPath, 'r+', onhandle); |
There was a problem hiding this comment.
Won't this break creating a new file if none exists? [1]
Fishrock123
commented
Apr 4, 2017
| if (err) { | ||
| return ready(err); | ||
| } | ||
| fs.ftruncate(hnd, 0, (err) => { |
There was a problem hiding this comment.
From what I am gathering, the mode change no longer cause overwrites (appends instead) and so we need to "flush" the file?
From the docs though, it sounds like it does writes and not appends, so this shouldn't be necessary?
'r+' - Open file for reading and writing. An exception occurs if the file does not exist.
There was a problem hiding this comment.
Previous implementation cleared the file once when opening it with w. This was the only place that would reset history file content - i.e. if one would set NODE_REPL_HISTORY_SIZE to value lower than 1000, then the history file would be trimmed when node starts. This ftruncate call here is to preserve this functionality.
ghost
commented
Apr 5, 2017
That's a good idea |
bzoz
commented
Apr 20, 2017
Windows test fail unrelated. Landed in bb041ea |
gibfahn
commented
May 16, 2017
Should this be backported to v6.x? |
mscdex
commented
May 26, 2017
Wherever this gets backported, we also need #12762. |
gibfahn
commented
Jun 18, 2017
Landed this with #12762, LMK if that wasn't a good idea. |
bzoz
commented
Jun 19, 2017
LGTM |
On Windows when REPL history file has the hidden attribute node will fail when trying to open it in
wmode. This changes the mode tor+. The file is guaranteed to exists because of earlier open call witha+.Fixes: #5261
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
repl