Commit d0f1671e authored by Julien Fontanet's avatar Julien Fontanet

chore: remove Bluebird dep

parent 2c009a43
......@@ -3,6 +3,9 @@ module.exports = {
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Promise": true
},
"parserOptions": {
"ecmaVersion": 5
},
......
import Bigint from '../tools/bigint';
import Bluebird from 'bluebird';
import { Readable } from 'stream';
import { request } from '../tools/smb2-forge';
const requestAsync = Bluebird.promisify(request);
const maxPacketSize = 0x00010000;
class SmbReadableStream extends Readable {
......@@ -40,7 +37,7 @@ class SmbReadableStream extends Readable {
const offset = new Bigint(this.offset);
this.wait = true;
let content = await requestAsync(
let content = await request(
'read',
{
FileId: this.file.FileId,
......@@ -62,7 +59,7 @@ class SmbReadableStream extends Readable {
}
if (this.offset.ge(this.fileLength)) {
this.push(null);
await requestAsync('close', this.file, this.connection);
await request('close', this.file, this.connection);
}
}
}
......
import Bigint from '../tools/bigint';
import Bluebird from 'bluebird';
import { request } from '../tools/smb2-forge';
import { Writable } from 'stream';
......@@ -10,8 +9,6 @@ import {
FILE_CREATE,
} from '../structures/constants';
const requestAsync = Bluebird.promisify(request);
const maxPacketSize = new Bigint(8, 0x00010000 - 0x71);
function* fibonacci() {
......@@ -54,7 +51,7 @@ class SmbWritableStream extends Writable {
while (pending) {
try {
await requestAsync(
await request(
'write',
{
FileId: this.file.FileId,
......@@ -84,7 +81,7 @@ class SmbWritableStream extends Writable {
try {
super.end(...args);
} finally {
await requestAsync('close', this.file, this.connection);
await request('close', this.file, this.connection);
}
}
}
......
import { request } from '../tools/smb2-forge';
import Bluebird from 'bluebird';
const requestAsync = Bluebird.promisify(request);
const ensureOneDir = async function(path, connection) {
try {
const fileOrDir = await requestAsync('open', { path }, connection);
const fileOrDir = await request('open', { path }, connection);
if (fileOrDir.FileAttributes.readIntBE(0, 1) === 0x00000010) {
// See http://download.microsoft.com/DOWNLOAD/9/5/E/95EF66AF-9026-4BB0-A41D-A4F81802D92C/[MS-FSCC].pdf Section 2.6
await requestAsync('close', fileOrDir, connection);
await request('close', fileOrDir, connection);
} else {
throw new Error(`${path} exists but is not a directory`);
}
} catch (err) {
if (err.code === 'STATUS_OBJECT_NAME_NOT_FOUND') {
try {
await requestAsync('create_folder', { path }, connection);
await request('create_folder', { path }, connection);
} catch (err) {
if (err.code !== 'STATUS_OBJECT_NAME_COLLISION') {
throw err;
......
......@@ -17,11 +17,24 @@ SMB2Forge.request = function(messageName, params, connection, cb) {
// send
sendNetBiosMessage(connection, smbMessage);
// wait for the response
var promise;
if (cb === undefined) {
promise = new Promise(function(resolve, reject) {
cb = function(err, result) {
if (err == null) {
resolve(result);
} else {
reject(err);
}
};
});
}
getResponse(
connection,
smbMessage.getHeaders().MessageId,
msg.parse(connection, cb)
);
return promise;
};
/*
......
......@@ -21,7 +21,6 @@
},
"dependencies": {
"babel-runtime": "^5.8.34",
"bluebird": "^2.10.2",
"ntlm": "~0.1.1"
},
"keywords": [
......
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