#Should "exists" function from STD be used as a last resort?

3 messages · Page 1 of 1 (latest)

unkempt lily
#

There was an undo deprecation for "exists" functions but still in the code it says this:

Note: Do not use this function if performing a check before another operation on that file. Doing so creates a race condition. Instead, perform the actual file operation directly.

So basically this message and the description in the PR, would mean use it but as last resort? e.g: third party scenarios?

Thanks.

https://github.com/denoland/deno_std/pull/2785

GitHub

Introduces readable Undos the deprecation and enhances exists of the fs module.
exists was deprecated due to TOCTOU issues, but there are valid use cases to have such function:

Checking for path a...

pastel tundra
#

Some valid use cases are mentioned in the pull requests. But indeed you should avoid using the function unless you really have to.

heady surge
#

for >95% of cases where you think you need it, you don’t and you’re doing it wrong