Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
repl: support hidden history file on Windows#12207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
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); |
Fishrock123Apr 4, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this break creating a new file if none exists? [1]
Fishrock123 commented Apr 4, 2017
jasnell left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green
| if(err){ | ||
| returnready(err); | ||
| } | ||
| fs.ftruncate(hnd,0,(err)=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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+'. Fixes: #5261 PR-URL: #12207 Reviewed-By: James M Snell <[email protected]>
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+'. Fixes: #5261 PR-URL: #12207 Reviewed-By: James M Snell <[email protected]>
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+'. Fixes: #5261 PR-URL: #12207 Reviewed-By: James M Snell <[email protected]>
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+'. Fixes: #5261 PR-URL: #12207 Reviewed-By: James M Snell <[email protected]>
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. |
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+'. Fixes: #5261 PR-URL: #12207 Reviewed-By: James M Snell <[email protected]>
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 'w' mode. This changes the mode to 'r+'. The file is guaranteed to exists because of earlier open call with 'a+'. Fixes: #5261 PR-URL: #12207 Reviewed-By: James M Snell <[email protected]>
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+'. Fixes: #5261 PR-URL: #12207 Reviewed-By: James M Snell <[email protected]>
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