Skip to content

Commit 9ea6771

Browse files
committed
Add further notes and research
1 parent ce31cd4 commit 9ea6771

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

filesystem-watcher-comparison.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,127 @@
44
* [fswatch](https://github.com/emcrisostomo/fswatch) - requires filters for removing noisy inotify `PlatformSpecific` events, and more critically doesn't detect object file creation during recursive monitorying (e.g doesn't detect creation of `.git/objects/56/26abf0f72e58d7a153368ba57db4c673c0e171`). `inotifywait` detects this, but has additional code around `inotify` to do so (see [issue #330](https://github.com/emcrisostomo/fswatch/issues/330)).
55
* [efsw](https://github.com/SpartanJ/efsw) - doesn't have a way to differentiate between files and directories (see [issue #191](https://github.com/SpartanJ/efsw/issues/191)).
66
* [Node.js fs.watch](https://nodejs.org/docs/latest/api/fs.html#fswatchfilename-options-listener) - only reports `'rename'` or `'change'` `eventType`s instead of create, delete, and update, and move. It also has caveats, and triggered wrapper projects such as [`node-watch`](https://github.com/yuanchuan/node-watch) and [`chokidar`](https://github.com/paulmillr/chokidar).
7+
8+
Both `fswatch` and Node.js `fs.watch` have issues that make them unworkable.
9+
10+
`dmon` and `efswatch` are workable since we can detect files between directories for Git based on names, length, and other attributes.
11+
12+
`efswatch` would be preferable since it's in Conan center, written in C++ as opposed to C, and seems a bit more popular and maintained.
13+
14+
## git add Comparison
15+
16+
Below is a comparison of output for the following command:
17+
```
18+
$ git add file
19+
```
20+
Where `file` is a plain-text file with the contents "`file`":
21+
```bash
22+
$ cat file
23+
file
24+
```
25+
26+
`efsw` output:
27+
```
28+
DIR (.git/) FILE (index.lock) has event Added
29+
DIR (.git/objects/) FILE (f7) has event Added
30+
DIR (.git/objects/f7/) FILE (tmp_obj_JUp4eR) has event Modified
31+
DIR (.git/objects/f7/) FILE (tmp_obj_JUp4eR) has event Modified
32+
DIR (.git/objects/f7/) FILE (3f3093ff865c514c6c51f867e35f693487d0d3) has event Added
33+
DIR (.git/objects/f7/) FILE (tmp_obj_JUp4eR) has event Delete
34+
DIR (.git/) FILE (index.lock) has event Modified
35+
DIR (.git/) FILE (index.lock) has event Modified
36+
DIR (.git/) FILE (index.lock) has event Modified
37+
DIR (.git/) FILE (index) has event Moved from (index.lock)
38+
````
39+
40+
`dmon` output:
41+
```
42+
{"filepath":".git/objects/f7","action":"CREATE"}
43+
{"filepath":".git/index","action":"MODIFY"}
44+
{"filepath":".git/objects/f7/3f3093ff865c514c6c51f867e35f693487d0d3","action":"CREATE"}
45+
```
46+
47+
`inotifywait` output (used as a source of truth):
48+
```
49+
$ inotifywait -m .git/ -r
50+
.git/ ACCESS HEAD
51+
.git/ CLOSE_NOWRITE,CLOSE HEAD
52+
.git/ OPEN config
53+
.git/ ACCESS config
54+
.git/ CLOSE_NOWRITE,CLOSE config
55+
.git/ OPEN config
56+
.git/ ACCESS config
57+
.git/ CLOSE_NOWRITE,CLOSE config
58+
.git/ OPEN config
59+
.git/ ACCESS config
60+
.git/ CLOSE_NOWRITE,CLOSE config
61+
.git/ CREATE index.lock
62+
.git/ OPEN index.lock
63+
.git/info/ OPEN exclude
64+
.git/info/ ACCESS exclude
65+
.git/info/ CLOSE_NOWRITE,CLOSE exclude
66+
.git/objects/ OPEN,ISDIR pack
67+
.git/objects/pack/ OPEN,ISDIR
68+
.git/objects/ ACCESS,ISDIR pack
69+
.git/objects/pack/ ACCESS,ISDIR
70+
.git/objects/ ACCESS,ISDIR pack
71+
.git/objects/pack/ ACCESS,ISDIR
72+
.git/objects/ CLOSE_NOWRITE,CLOSE,ISDIR pack
73+
.git/objects/pack/ CLOSE_NOWRITE,CLOSE,ISDIR
74+
.git/objects/ CREATE,ISDIR f7
75+
.git/objects/ OPEN,ISDIR f7
76+
.git/objects/ ACCESS,ISDIR f7
77+
.git/objects/ CLOSE_NOWRITE,CLOSE,ISDIR f7
78+
.git/objects/f7/ MODIFY tmp_obj_JUp4eR
79+
.git/objects/f7/ CLOSE_WRITE,CLOSE tmp_obj_JUp4eR
80+
.git/objects/f7/ CREATE 3f3093ff865c514c6c51f867e35f693487d0d3
81+
.git/objects/f7/ DELETE tmp_obj_JUp4eR
82+
.git/ MODIFY index.lock
83+
.git/ CLOSE_WRITE,CLOSE index.lock
84+
.git/ MOVED_FROM index.lock
85+
.git/ MOVED_TO index
86+
.git/ OPEN HEAD
87+
.git/ ACCESS HEAD
88+
.git/ CLOSE_NOWRITE,CLOSE HEAD
89+
.git/ OPEN config
90+
.git/ ACCESS config
91+
.git/ CLOSE_NOWRITE,CLOSE config
92+
.git/ OPEN config
93+
.git/ ACCESS config
94+
.git/ CLOSE_NOWRITE,CLOSE config
95+
.git/ OPEN HEAD
96+
.git/ ACCESS HEAD
97+
.git/ CLOSE_NOWRITE,CLOSE HEAD
98+
.git/ OPEN HEAD
99+
.git/ ACCESS HEAD
100+
.git/ CLOSE_NOWRITE,CLOSE HEAD
101+
.git/ OPEN HEAD
102+
.git/ ACCESS HEAD
103+
.git/ CLOSE_NOWRITE,CLOSE HEAD
104+
.git/ OPEN config
105+
.git/ ACCESS config
106+
.git/ CLOSE_NOWRITE,CLOSE config
107+
.git/ OPEN config
108+
.git/ ACCESS config
109+
.git/ CLOSE_NOWRITE,CLOSE config
110+
.git/ OPEN config
111+
.git/ ACCESS config
112+
.git/ CLOSE_NOWRITE,CLOSE config
113+
.git/ OPEN HEAD
114+
.git/ ACCESS HEAD
115+
.git/ CLOSE_NOWRITE,CLOSE HEAD
116+
.git/ OPEN HEAD
117+
.git/ ACCESS HEAD
118+
.git/ CLOSE_NOWRITE,CLOSE HEAD
119+
.git/ OPEN config
120+
.git/ ACCESS config
121+
.git/ CLOSE_NOWRITE,CLOSE config
122+
.git/ OPEN config
123+
.git/ ACCESS config
124+
.git/ CLOSE_NOWRITE,CLOSE config
125+
.git/ OPEN config
126+
.git/ ACCESS config
127+
.git/ CLOSE_NOWRITE,CLOSE config
128+
```
129+
130+
`dmon` doesn't detect git creating the `index.lock`, `index` or `tmp_obj_JUp4eR`. These aren't really important, but it's concerning that events are swallowed leading to an inaccurate picture.

0 commit comments

Comments
 (0)