Skip to content

Commit

Permalink
vfs: Don't clear the root nodes when stat fails. (KurokuLabs#124)
Browse files Browse the repository at this point in the history
This appears to be the main cause of DisposaBoy/GoSublime#957.
At least on Windows (maybe poor filepath->vfspath handling), we sometimes end up statting the root node,
and when it fails (because it has no path), we clear its nodes and thus remove all cached data.
  • Loading branch information
DisposaBoy authored Feb 1, 2020
1 parent f95faf4 commit a93456f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions vfs/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,14 @@ func (nd *Node) sync() (*meta, error) {
nd.resetParent()
}
if err != nil {
mt.invalidate()
nd.setCl(nil)
// don't reset root, it gets rid of all nodes below it...
// TODO: investigate how we end up statting the root node (at least on Windows)
// TODO: cache these stat errors for a little while;
// if a file doesn't exist, it's unlikely to exist a couple seconds later.
if !nd.IsRoot() {
mt.invalidate()
nd.setCl(nil)
}
return nil, err
}
mt.resetInfo(fi.Mode(), fi.ModTime())
Expand Down

0 comments on commit a93456f

Please sign in to comment.