Delete ExternalTools directory on Npm Cache Clear#1053
Delete ExternalTools directory on Npm Cache Clear#1053mjbvz merged 5 commits intomicrosoft:masterfrom
Conversation
This change updates the npm cache clear button to also delete our ExternalTools directory. This directory contains node packages used internally by NTVS, so we want to provide a way to delete it if users get in a bad state. Also extracted the localappdata paths for NTVS to constants. closes microsoft#1044
| _cacheClearedSuccessfully.Visible = true; | ||
| return true; | ||
| } catch (IOException exception) { | ||
| // files are in use or path is too long |
There was a problem hiding this comment.
Huh, just now realizing this case might be pretty likely in the case of typings... what's the max path length of typings?
There was a problem hiding this comment.
Here was the script I used:
C:\Users\matb.REDMOND\AppData\Local\Microsoft\Node.js Tools> Get-ChildItem -Recurse . | % { $_.fullname } | sort -Property LengthLongest path is 150 characters with Node 6 and my relatively short user name.
There was a problem hiding this comment.
On < Node 6, the max path was 273 :sad:
I changed the logic to use robocopy to nuke the directory instead. This was tested with Node 6 and Node 0.12, and both seem to work fine now.
For reference, another way to delete long path files is with the Windows DeleteFile function:
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\?" to the path.
|
Left some comments... we may want to reconsider our approach here if we think that we are significantly more likely to fail to delete typings than we are to delete the existing cache directory. |
| // Directory has already been deleted. Do nothing. | ||
| _cacheClearedSuccessfully.Visible = true; | ||
| } catch (IOException exception) { | ||
| // To handle long paths, nuke the directory contents with robocopy |
There was a problem hiding this comment.
nit: nuke -> exterminate 🤖
|
👍 |
This change updates the npm cache clear button to also delete our ExternalTools directory. This directory contains node packages used internally by NTVS, so we want to provide a way to delete it if users get in a bad state.
Also extracted the localappdata paths for NTVS to constants.
closes #1044