Skip to content

Commit

Permalink
fix(watchman): allow watching workspaces at /tmp/some-dir
Browse files Browse the repository at this point in the history
Fixes #4616
  • Loading branch information
oxalica committed May 8, 2023
1 parent 3014125 commit 90919db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/__tests__/core/fileSystemWatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ describe('isValidWatchRoot()', () => {
it('should check valid root', async () => {
expect(isValidWatchRoot('/')).toBe(false)
expect(isValidWatchRoot(os.homedir())).toBe(false)
expect(isValidWatchRoot('/tmp/a/b/c')).toBe(false)
expect(isValidWatchRoot(os.tmpdir())).toBe(false)
expect(isValidWatchRoot('/tmp/a')).toBe(true)
expect(isValidWatchRoot('/tmp/a/b/c')).toBe(true)
})
})

Expand Down
6 changes: 2 additions & 4 deletions src/core/watchman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,11 @@ export default class Watchman {
}

/**
* Exclude user's home, driver, tmpdir
* Exclude root, user's home, driver and tmpdir, but allow sub-directories under them.
*/
export function isValidWatchRoot(root: string): boolean {
if (root == '/' || root == '/tmp' || root == '/private/tmp') return false
if (root == '/' || root == '/tmp' || root == '/private/tmp' || root == os.tmpdir()) return false
if (isParentFolder(root, os.homedir(), true)) return false
if (path.parse(root).base == root) return false
if (root.startsWith('/tmp/') || root.startsWith('/private/tmp/')) return false
if (isParentFolder(os.tmpdir(), root, true)) return false
return true
}

0 comments on commit 90919db

Please sign in to comment.