-
-
Notifications
You must be signed in to change notification settings - Fork 962
Description
Previously, if Add was called on a file that doesn't exist, a syscall.ENOENT error would be returned. We used this to handle the case where the file may or may not exists, e.g.:
err = watcher.Add(lockFile)
if err != nil {
if errors.Is(err, syscall.ENOENT) {
...
}
...
}As of #289, this error is now returned:
Line 76 in e2e9517
| return fmt.Errorf("error resolving %#v: %s", name, err) |
Given that this is a new error that doesn't wrap the original error, the only option to check if the cause is that the file doesn't exist is to try to match against the error message. This seems fragile and is an API change.
We rely on the syscall.ENOENT error from the Add as checking whether the file exists before the Add would just introduce a race condition, where the file could be remove after the check but before the Add.
Note: we have worked around this by switching to AddRaw, but the behavior on Add could be improved.