Skip to content

Error change in 1.5.0 when adding a file that doesn't exist #393

@oschwald

Description

@oschwald

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions