forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
detect when cookie dir has gone awol
Summary: I got here because `btrfs` doesn't send `IN_DELETE_SELF` notifications when a watched subvolume is unmounted. Until that is addresses in the kernel we tackle this from a different angle. We periodically perform a synchronized `clock` call against each of the watches. When that happens and a btrfs volume has been deleted then the cookie sync will error out because the directory structure no longer exists. Let's catch that case and generate a recrawl; the recrawl will discover the removal and cancel the watch. And while we're in here, let's also deal with just the vcs subdir going away. Refs: facebook#25 Refs: facebook#501 Reviewed By: simpkins Differential Revision: D7014364 fbshipit-source-id: 9acd20efa843563626b73c6f6e34c3787dd28a39
- Loading branch information
Showing
2 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# vim:ts=4:sw=4:et: | ||
# Copyright 2018-present Facebook, Inc. | ||
# Licensed under the Apache License, Version 2.0 | ||
|
||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
# no unicode literals | ||
|
||
import WatchmanTestCase | ||
import os | ||
import pywatchman | ||
|
||
|
||
@WatchmanTestCase.expand_matrix | ||
class TestCookie(WatchmanTestCase.WatchmanTestCase): | ||
|
||
def test_delete_cookie_dir(self): | ||
root = self.mkdtemp() | ||
cookie_dir = os.path.join(root, '.hg') | ||
os.mkdir(cookie_dir) | ||
self.touchRelative(root, 'foo') | ||
|
||
self.watchmanCommand('watch-project', root) | ||
self.assertFileList(root, files=['foo', '.hg']) | ||
|
||
os.rmdir(cookie_dir) | ||
self.assertFileList(root, files=['foo']) | ||
os.unlink(os.path.join(root, 'foo')) | ||
self.assertFileList(root, files=[]) | ||
os.rmdir(root) | ||
with self.assertRaises(pywatchman.WatchmanError) as ctx: | ||
self.assertFileList(root, files=[]) | ||
reason = str(ctx.exception) | ||
self.assertTrue( | ||
('No such file' in reason) or | ||
('unable to resolve root' in reason), | ||
msg=reason) |