Commit 80b74f0a authored by Julien Fontanet's avatar Julien Fontanet

chore: format with Prettier

parent 7f5124b0
...@@ -16,7 +16,7 @@ module.exports = function createReadStream(path, options, cb) { ...@@ -16,7 +16,7 @@ module.exports = function createReadStream(path, options, cb) {
var fd = options.fd; var fd = options.fd;
var isFd = fd != null; var isFd = fd != null;
var shouldClose = !isFd || (options.autoClose == null || options.autoClose); var shouldClose = !isFd || options.autoClose == null || options.autoClose;
function onOpen(err, file) { function onOpen(err, file) {
if (err != null) { if (err != null) {
......
...@@ -15,7 +15,7 @@ module.exports = function createWriteStream(path, options, cb) { ...@@ -15,7 +15,7 @@ module.exports = function createWriteStream(path, options, cb) {
var fd = options.fd; var fd = options.fd;
var isFd = fd != null; var isFd = fd != null;
var shouldClose = !isFd || (options.autoClose == null || options.autoClose); var shouldClose = !isFd || options.autoClose == null || options.autoClose;
function onCreate(err, file) { function onCreate(err, file) {
if (err != null) { if (err != null) {
......
...@@ -31,7 +31,11 @@ module.exports = function rename(oldPath, newPath, options, cb) { ...@@ -31,7 +31,11 @@ module.exports = function rename(oldPath, newPath, options, cb) {
if (err) if (err)
SMB2Request( SMB2Request(
'create', 'create',
{ path: oldPath, createDisposition: constants.FILE_OPEN, shareAccess: constants.FILE_SHARE_DELETE }, {
path: oldPath,
createDisposition: constants.FILE_OPEN,
shareAccess: constants.FILE_SHARE_DELETE,
},
connection, connection,
function(err, file) { function(err, file) {
if (err) cb && cb(err); if (err) cb && cb(err);
......
...@@ -19,24 +19,29 @@ module.exports = function unlink(path, cb) { ...@@ -19,24 +19,29 @@ module.exports = function unlink(path, cb) {
var connection = this; var connection = this;
// SMB2 open file // SMB2 open file
SMB2Request('create', { path: path, shareAccess: constants.FILE_SHARE_DELETE }, connection, function(err, file) { SMB2Request(
if (err) cb && cb(err); 'create',
// SMB2 query directory { path: path, shareAccess: constants.FILE_SHARE_DELETE },
else connection,
SMB2Request( function(err, file) {
'set_info', if (err) cb && cb(err);
{ // SMB2 query directory
FileId: file.FileId, else
FileInfoClass: 'FileDispositionInformation', SMB2Request(
Buffer: new BigInt(1, 1).toBuffer(), 'set_info',
}, {
connection, FileId: file.FileId,
function(err, files) { FileInfoClass: 'FileDispositionInformation',
SMB2Request('close', file, connection, function() { Buffer: new BigInt(1, 1).toBuffer(),
if (err) cb && cb(err); },
else cb && cb(null, files); connection,
}); function(err, files) {
} SMB2Request('close', file, connection, function() {
); if (err) cb && cb(err);
}); else cb && cb(null, files);
});
}
);
}
);
}; };
...@@ -28,30 +28,27 @@ SMB2Connection.requireConnect = function(method) { ...@@ -28,30 +28,27 @@ SMB2Connection.requireConnect = function(method) {
return function() { return function() {
var connection = this; var connection = this;
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
connect( connect(connection, function(err) {
connection, // process the cb
function(err) { var cb = args.pop();
// process the cb if (typeof cb !== 'function') {
var cb = args.pop();
if (typeof cb !== 'function') {
args.push(cb);
cb = function(err) {
if (err) {
if (!(err instanceof Error)) {
err = new Error(String(err));
}
throw err;
}
};
}
cb = scheduleAutoClose(connection, cb);
args.push(cb); args.push(cb);
cb = function(err) {
// manage the connection error if (err) {
if (err) cb(err); if (!(err instanceof Error)) {
else method.apply(connection, args); err = new Error(String(err));
}
throw err;
}
};
} }
); cb = scheduleAutoClose(connection, cb);
args.push(cb);
// manage the connection error
if (err) cb(err);
else method.apply(connection, args);
});
}; };
}; };
...@@ -97,10 +94,7 @@ function connect(connection, cb) { ...@@ -97,10 +94,7 @@ function connect(connection, cb) {
connection.SessionId = Math.floor(Math.random() * 256) & 0xff; connection.SessionId = Math.floor(Math.random() * 256) & 0xff;
// open TCP socket // open TCP socket
connection.socket.connect( connection.socket.connect(connection.port, connection.ip);
connection.port,
connection.ip
);
// SMB2 negotiate connection // SMB2 negotiate connection
SMB2Request('negotiate', {}, connection, function(err) { SMB2Request('negotiate', {}, connection, function(err) {
......
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