Commit f30bfccc authored by Julien Fontanet's avatar Julien Fontanet

fix(exists): properly handle errors

parent 842db5f6
......@@ -16,10 +16,18 @@ module.exports = function exists(path, cb) {
var connection = this;
SMB2Request('open', { path: path }, connection, function(err, file) {
if (err) cb && cb(null, false);
else
SMB2Request('close', file, connection, function() {
cb && cb(null, true);
});
if (err != null) {
if (
err.code === 'STATUS_OBJECT_NAME_NOT_FOUND' ||
err.code === 'STATUS_OBJECT_PATH_NOT_FOUND'
) {
return cb && cb(null, false);
}
return cb && cb(err);
}
SMB2Request('close', file, connection, function() {
cb && cb(null, true);
});
});
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment