Skip to content

Commit b99ca7d

Browse files
committed
Manual add stat_ignore_enoent() to 5.18.4
Signed-off-by: Romy <[email protected]>
1 parent 6d4607a commit b99ca7d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/util/native_fs_utils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,19 @@ function should_retry_link_unlink(err) {
289289
return should_retry_general || should_retry_gpfs || should_retry_posix;
290290
}
291291

292+
/**
293+
* stat_ignore_enoent unlinks a file and if recieved an ENOENT error it'll not fail
294+
* @param {nb.NativeFSContext} fs_context
295+
* @param {string} file_path
296+
* @returns {Promise<nb.NativeFSStats>}
297+
*/
298+
async function stat_ignore_enoent(fs_context, file_path) {
299+
try {
300+
return await nb_native().fs.stat(fs_context, file_path);
301+
} catch (err) {
302+
if (err.code !== 'ENOENT') throw err;
303+
}
304+
}
292305

293306
/**
294307
* stat_if_exists execute stat on entry_path and ignores on certain error codes.
@@ -729,6 +742,7 @@ exports.finally_close_files = finally_close_files;
729742
exports.get_user_by_distinguished_name = get_user_by_distinguished_name;
730743
exports.get_config_files_tmpdir = get_config_files_tmpdir;
731744
exports.stat_if_exists = stat_if_exists;
745+
exports.stat_ignore_enoent = stat_ignore_enoent;
732746

733747
exports._is_gpfs = _is_gpfs;
734748
exports.safe_move = safe_move;

0 commit comments

Comments
 (0)