You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
file_system: group promisify, avoid relying on in-advance fs.exists checks (tensorflow#112)
* file_system: move promisify to top
No need to call promisify() per every method call,
we can do that once instead and save the result.
* file_system: avoid relying on in-advance fs.exists check in dir creation
This avoids possible race conditions, e.g. when more than one
parallel async .save() operation is called (from a single or several
processes) sharing a common prefix which does not yet exist.
Instead, createOrVerifyDirectory() now just tries creating the dir,
and if that fails -- checks _why_ that failed, if it is anything
other than the directory already existing -- throws an error, if
it's the dir already existing -- skips that and continues.
Refs: https://nodejs.org/api/fs.html#fs_fs_exists_path_callback
* file_system: remove remaining fs.exists calls
Instead, use fs.stat and fs.readFile directly and let them throw if
the file in question does not exist, and format the error in a way
how we want using a small helper function.
0 commit comments