From 5e3c57e0e470d4a07c35ef8c5982aa39daeafa09 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Richardet Date: Wed, 6 Nov 2019 16:44:42 +0100 Subject: [PATCH] 2.0.8 --- CHANGELOG.md | 18 +-- docs/BatchError.html | 4 +- docs/DropboxConnector.html | 12 +- docs/FsConnector.html | 33 +++++- docs/FtpConnector.html | 4 +- docs/GitHubConnector.html | 6 +- docs/RemoteStorageConnector.html | 4 +- docs/SftpConnector.html | 4 +- docs/Unifile.html | 4 +- docs/UnifileError.html | 4 +- docs/error.js.html | 2 +- docs/external-Promise.html | 2 +- docs/external-ReadableStream.html | 2 +- docs/external-WritableStream.html | 2 +- docs/global.html | 2 +- docs/index.html | 42 ++++--- docs/index.js.html | 2 +- docs/unifile-dropbox.js.html | 2 +- docs/unifile-fs.js.html | 2 +- docs/unifile-ftp.js.html | 170 ++++++++++++----------------- docs/unifile-github.js.html | 32 ++++-- docs/unifile-remoteStorage.js.html | 2 +- docs/unifile-sftp.js.html | 10 +- package-lock.json | 2 +- package.json | 2 +- 25 files changed, 200 insertions(+), 169 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f59a55c..63fe2a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,34 +3,34 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased] +## [] - 2019-11-06 ### Fixed - [FTP] FTP client has been replace, thus fixing multiple bugs like stat - [SFTP] Fix an issue when listing or stating with an empty path - [GitHub] Gracefully handle scopes and permissions - [Node] Update minimal version of Node to 8 -## [2.0.4] - 2018-10-08 +## [2.0.4] - 2018-10-08 - 2019-11-06 ### Fixed - [FTP] Handles FTP server that return an empty list on 404 (like OVH) -## [2.0.3] - 2018-03-25 +## [2.0.3] - 2018-03-25 - 2019-11-06 ### Fixed - [FTP] Prevents server crash when unable to connect to server (https://github.com/silexlabs/CloudExplorer2/issues/57) -## [2.0.2] - 2018-03-10 +## [2.0.2] - 2018-03-10 - 2019-11-06 ### Fixed - [GitHub] OAuth scopes are provided in request headers (https://github.com/silexlabs/unifile/issues/123) - [GitHub] Fix batch update with multi levels tree -## [2.0.1] - 2017-12-11 - 2018-03-10 +## [2.0.1] - 2017-12-11 - 2018-03-10 - 2019-11-06 ### Fixed - [Dropbox] Batch correctly overwrite existing files (https://github.com/silexlabs/unifile/issues/131) - [Dropbox] Batch now correctly rejects the promise if one action failed (https://github.com/silexlabs/unifile/issues/131) - [Dropbox] Batch upload uses `Buffer` for file content and supports UTF-8 (https://github.com/silexlabs/unifile/issues/130) - [Dropbox] All the methods support non-ASCII char in filename and content (https://github.com/silexlabs/unifile/issues/134) -## [2.0.0] - 2017-11-25 - 2018-03-10 +## [2.0.0] - 2017-11-25 - 2018-03-10 - 2019-11-06 ### Changed - GitHub batch fixes and optimization - Code factorization @@ -52,7 +52,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - WebDAV connector is now a separate plugin - `unifile.connectors` is now private -## [1.2.0] - 2017-06-01 - 2017-11-25 - 2018-03-10 +## [1.2.0] - 2017-06-01 - 2017-11-25 - 2018-03-10 - 2019-11-06 ### Added - SFTP support - `.stat()` method that return information abouth the given path @@ -70,7 +70,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Includes connector documentation to the global one - Includes README in documentation -## [1.1.0] - 2017-04-26 - 2017-11-25 - 2018-03-10 +## [1.1.0] - 2017-04-26 - 2017-11-25 - 2018-03-10 - 2019-11-06 ### Added - Local filesystem support @@ -78,7 +78,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Changed - Total rework of the philosphy -[Unreleased]: https://github.com/silexlabs/unifile/compare/v2.0.3...HEAD +[]: https://github.com/silexlabs/unifile/compare/v2.0.3...v [2.0.3]: https://github.com/silexlabs/unifile/compare/v2.0.2...v2.0.3 [2.0.2]: https://github.com/silexlabs/unifile/compare/v2.0.1...v2.0.2 [2.0.1]: https://github.com/silexlabs/unifile/compare/v2.0.0...v2.0.1 diff --git a/docs/BatchError.html b/docs/BatchError.html index adb3727..be063fd 100644 --- a/docs/BatchError.html +++ b/docs/BatchError.html @@ -70,7 +70,7 @@

new BatchEr
Source:
@@ -165,7 +165,7 @@

new BatchEr
- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/DropboxConnector.html b/docs/DropboxConnector.html index a0c47e9..160d0b8 100644 --- a/docs/DropboxConnector.html +++ b/docs/DropboxConnector.html @@ -45,9 +45,9 @@

Service connector for Dropbox plateform.

This will need a registered Dropbox application with valid redirection for your server. -You can register a new application here">www.dropbox.com/developers/apps|here} and +You can register a new application here and learn more about Dropbox OAuth Web application flow -here">www.dropbox.com/developers/reference/oauth-guide|here}

+here

@@ -73,7 +73,7 @@

new D
Source:
@@ -331,8 +331,8 @@

Properties

Write mode when files conflicts. Must be one of - 'add'/'overwrite'/'update'. -see">www.dropbox.com/developers/documentation/http/documentation#files-upload|see Dropbox manual

+'add'/'overwrite'/'update'. +see Dropbox manual

@@ -430,7 +430,7 @@
Properties

diff --git a/docs/FsConnector.html b/docs/FsConnector.html index 946949e..4964ad5 100644 --- a/docs/FsConnector.html +++ b/docs/FsConnector.html @@ -69,7 +69,7 @@

new FsConn
Source:
@@ -362,6 +362,35 @@

Properties
+
Throws:
+ + + +
+
+
+

Invalid sandbox path.

+
+
+
+
+
+
+ Type +
+
+ +Error + + +
+
+
+
+
+ + + @@ -398,7 +427,7 @@
Properties

diff --git a/docs/FtpConnector.html b/docs/FtpConnector.html index 2c12ca7..70063c4 100644 --- a/docs/FtpConnector.html +++ b/docs/FtpConnector.html @@ -69,7 +69,7 @@

new FtpCo
Source:
@@ -354,7 +354,7 @@

Properties

diff --git a/docs/GitHubConnector.html b/docs/GitHubConnector.html index 00de450..e716e63 100644 --- a/docs/GitHubConnector.html +++ b/docs/GitHubConnector.html @@ -73,7 +73,7 @@

new Gi
Source:
@@ -294,7 +294,7 @@

Properties

GitHub application redirect URI. - You still need to register it in your GitHub App

+You still need to register it in your GitHub App

@@ -470,7 +470,7 @@
Properties

diff --git a/docs/RemoteStorageConnector.html b/docs/RemoteStorageConnector.html index e6cfedc..d5c399b 100644 --- a/docs/RemoteStorageConnector.html +++ b/docs/RemoteStorageConnector.html @@ -70,7 +70,7 @@

Source:
@@ -337,7 +337,7 @@

Properties

diff --git a/docs/SftpConnector.html b/docs/SftpConnector.html index 789452f..07250a2 100644 --- a/docs/SftpConnector.html +++ b/docs/SftpConnector.html @@ -69,7 +69,7 @@

new Sftp
Source:
@@ -354,7 +354,7 @@

Properties

diff --git a/docs/Unifile.html b/docs/Unifile.html index 1311f2d..fbcfb05 100644 --- a/docs/Unifile.html +++ b/docs/Unifile.html @@ -696,7 +696,7 @@
Parameters:

Service credentials (user/password or OAuth code) - or a authenticated URL to connect to the service.

+or a authenticated URL to connect to the service.

@@ -3807,7 +3807,7 @@
Returns:

diff --git a/docs/UnifileError.html b/docs/UnifileError.html index 0beb3cb..aa5f922 100644 --- a/docs/UnifileError.html +++ b/docs/UnifileError.html @@ -69,7 +69,7 @@

new Unifi
Source:
@@ -164,7 +164,7 @@

new Unifi
- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/error.js.html b/docs/error.js.html index 9018e26..7e911f8 100644 --- a/docs/error.js.html +++ b/docs/error.js.html @@ -93,7 +93,7 @@

error.js


diff --git a/docs/external-Promise.html b/docs/external-Promise.html index 945953e..b30b56e 100644 --- a/docs/external-Promise.html +++ b/docs/external-Promise.html @@ -138,7 +138,7 @@


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/external-ReadableStream.html b/docs/external-ReadableStream.html index 96853f5..dfd1d32 100644 --- a/docs/external-ReadableStream.html +++ b/docs/external-ReadableStream.html @@ -138,7 +138,7 @@


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/external-WritableStream.html b/docs/external-WritableStream.html index 89d9c4e..e378da6 100644 --- a/docs/external-WritableStream.html +++ b/docs/external-WritableStream.html @@ -138,7 +138,7 @@


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/global.html b/docs/global.html index 2856e07..fb99119 100644 --- a/docs/global.html +++ b/docs/global.html @@ -1593,7 +1593,7 @@

Type:

diff --git a/docs/index.html b/docs/index.html index a5ce437..48a1ad5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -46,7 +46,8 @@

Home

Classes

-

Roadmap

Let's discuss this list of issues which set the future of unifile

+

Roadmap

+

Let's discuss this list of issues which set the future of unifile

@@ -105,7 +121,7 @@

Roadmap

Let's discuss

diff --git a/docs/index.js.html b/docs/index.js.html index 08763dd..2e07773 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -406,7 +406,7 @@

index.js


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/unifile-dropbox.js.html b/docs/unifile-dropbox.js.html index c8d4515..58c7a50 100644 --- a/docs/unifile-dropbox.js.html +++ b/docs/unifile-dropbox.js.html @@ -642,7 +642,7 @@

unifile-dropbox.js


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/unifile-fs.js.html b/docs/unifile-fs.js.html index 9ec946b..b76efde 100644 --- a/docs/unifile-fs.js.html +++ b/docs/unifile-fs.js.html @@ -242,7 +242,7 @@

unifile-fs.js


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/unifile-ftp.js.html b/docs/unifile-ftp.js.html index 6732249..a461029 100644 --- a/docs/unifile-ftp.js.html +++ b/docs/unifile-ftp.js.html @@ -42,7 +42,7 @@

unifile-ftp.js

const PassThrough = require('stream').PassThrough; const Promise = require('bluebird'); -const Ftp = require('jsftp'); +const Ftp = require('basic-ftp'); const Mime = require('mime'); const Tools = require('unifile-common-tools'); @@ -56,86 +56,75 @@

unifile-ftp.js

* @return {Promise<Ftp>} a promise for a FTP client */ function getClient(credentials) { - return new Promise((resolve, reject) => { - const ftp = new Ftp(credentials); - ftp.once('connect', () => { - resolve(ftp); - }); - }); + const ftp = new Ftp.Client(); + return ftp.access(credentials) + .then(() => ftp); } function callAPI(session, action, client, ...params) { function execute(ftpClient) { - return new Promise((resolve, reject) => { - const handler = (err, res) => { - if(err) reject(err); - else resolve(res); - }; - // Makes paths in params absolute - const absParams = params.map((p) => { - if(p.constructor === String) return '/' + p; - return p; - }); - switch (action) { - case 'delete': - ftpClient.raw('DELE', ...absParams, handler); - break; - case 'rmdir': - ftpClient.raw('RMD', ...absParams, handler); - break; - case 'mkdir': - ftpClient.raw('MKD', ...absParams, handler); - break; - default: - ftpClient[action](...absParams, handler); - } + // Makes paths in params absolute + const absParams = params.map((p) => { + if(p.constructor === String) return '/' + p; + return p; }); + switch (action) { + case 'ls': + case 'stat': + return ftpClient.list(...absParams); + case 'put': + return ftpClient.upload(...absParams); + case 'get': + return ftpClient.download(...absParams); + case 'rename': + return ftpClient.rename(...absParams); + case 'delete': + return ftpClient.remove(...absParams); + case 'rmdir': + return ftpClient.removeDir(...absParams); + case 'mkdir': + return ftpClient.send(`MKD ${absParams[0]}`); + default: + throw new UnifileError(UnifileError.ENOTSUP, `Unsupported FTP command ${action}`); + } } let ftp = client; let promise = null; - if(client) { - promise = execute(client); + if(ftp) { + promise = execute(ftp); } else { promise = getClient(session) - .then((client) => { - ftp = client; - // Adds a error handler on the client - return Promise.race([ - new Promise((resolve, reject) => { - ftp.on('error', (err) => { - ftp.destroy(); - reject(err); - }); - }), - execute(ftp) - ]); + .then((ftpClient) => { + ftp = ftpClient; + return execute(ftp); }); } return promise.catch((err) => { if(err.code === 530) { throw new UnifileError(UnifileError.EACCES, 'Invalid credentials'); + } else if(err.code >= 400 && err.code < 500) { + throw new UnifileError(UnifileError.ENOENT, 'Not found'); } throw new UnifileError(UnifileError.EIO, err.message); }) .then((result) => { // Client was not provided, we can close it if(!client && result && !result.readable) { - ftp.destroy(); + ftp.close(); } return result; }); } function toFileInfos(entry) { - const isDir = entry.type === 1; return { - size: parseInt(entry.size, 10), - modified: new Date(entry.time).toISOString(), - name: entry.name, - isDir: isDir, - mime: isDir ? 'application/directory' : Mime.getType(entry.name) + size: entry.size, + modified: new Date(entry.date).toISOString(), + name: entry.name.split('/').pop(), + isDir: entry.isDirectory, + mime: entry.isDirectory ? 'application/directory' : Mime.getType(entry.name) }; } @@ -196,19 +185,8 @@

unifile-ftp.js

return Promise.reject(e); } - return new Promise((resolve, reject) => { - const client = new Ftp(ftpConf); - client.on('error', (err) => { - reject(err); - }); - // Successful connection - client.once('connect', () => { - client.auth(ftpConf.user, ftpConf.password, (err) => { - if(err) reject(err); - else resolve(); - }); - }); - }) + const client = new Ftp.Client(); + return client.access(ftpConf) .catch((err) => { if(err.code === 'ETIMEDOUT') throw new UnifileError(UnifileError.EIO, 'Unable to reach server'); @@ -235,23 +213,18 @@

unifile-ftp.js

} stat(session, path, ftpSession) { - return callAPI(session, 'ls', ftpSession, path) - .then((entries) => { - // Not found - if(entries.length === 0) throw new UnifileError(UnifileError.ENOENT, 'Not found'); - // It's a file - if(entries.length === 1) return toFileInfos(entries[0]); - // It's a folder - const lastTime = entries.reduce((memo, stat) => { - // eslint-disable-next-line no-param-reassign - if(stat.time > memo) memo = stat.time; - return memo; - }, 0); - return toFileInfos({ - name: path.split('/').pop(), - type: 1, - time: lastTime - }); + return callAPI(session, 'stat', ftpSession, path) + .then((result) => { + if(result.length > 1) + // It's a folder + return { + size: 4096, + modified: new Date(Math.min(...result.map((entry) => new Date(entry.date).getTime()))).toISOString(), + name: path, + isDir: true, + mime: 'application/directory' + }; + else return toFileInfos(result[0]); }); } @@ -260,7 +233,9 @@

unifile-ftp.js

} writeFile(session, path, data, ftpSession) { - return callAPI(session, 'put', ftpSession, new Buffer(data), path); + const stream = new PassThrough(); + stream.end(data); + return callAPI(session, 'put', ftpSession, stream, path); } createWriteStream(session, path, ftpSession) { @@ -270,19 +245,15 @@

unifile-ftp.js

} readFile(session, path, ftpSession) { - const promise = ftpSession ? Promise.resolve(ftpSession) : getClient(session); - return promise.then((client) => { - return callAPI(session, 'get', client, path) - .then((fileStream) => { - return new Promise((resolve, reject) => { - const chunks = []; - fileStream.on('data', (chunk) => chunks.push(chunk)); - fileStream.on('end', () => resolve(Buffer.concat(chunks))); - fileStream.on('error', (err) => { - client.end(); - reject(err); - }); - fileStream.resume(); + var fileStream = new PassThrough(); + return callAPI(session, 'get', ftpSession, fileStream, path) + .then(() => { + return new Promise((resolve, reject) => { + const chunks = []; + fileStream.on('data', (chunk) => chunks.push(chunk)); + fileStream.on('end', () => resolve(Buffer.concat(chunks))); + fileStream.on('error', (err) => { + reject(err); }); }); }); @@ -290,13 +261,8 @@

unifile-ftp.js

createReadStream(session, path, ftpSession) { var through = new PassThrough(); - callAPI(session, 'get', ftpSession, path) - .then((fileStream) => { - fileStream.pipe(through); - fileStream.resume(); - }) + callAPI(session, 'get', ftpSession, through, path) .catch((err) => through.emit('error', err)); - return through; } @@ -349,7 +315,7 @@

unifile-ftp.js


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/unifile-github.js.html b/docs/unifile-github.js.html index 4f09c17..d49ff75 100644 --- a/docs/unifile-github.js.html +++ b/docs/unifile-github.js.html @@ -50,7 +50,7 @@

unifile-github.js

const NAME = 'github'; const SERVICE_HOST = 'github.com'; -const APP_PERMISSION = 'scope=repo,delete_repo,user'; +const DEFAULT_APP_PERMISSION = 'scope=repo,delete_repo,user'; const {UnifileError, BatchError} = require('./error.js'); @@ -163,6 +163,7 @@

unifile-github.js

this.serviceHost = config.serviceHost || SERVICE_HOST; this.oauthCallbackUrl = `https://${this.serviceHost}/login/oauth`; this.redirectUri = config.redirectUri || null; + this.permission = config.permission || DEFAULT_APP_PERMISSION; this.infos = Tools.mergeInfos(config.infos, { name: NAME, @@ -218,11 +219,16 @@

unifile-github.js

if(err) reject(new UnifileError(UnifileError.EINVAL, 'Error while calling GitHub API. ' + err)); else if(response.statusCode >= 400 || 'error' in body) reject(new UnifileError(UnifileError.EACCES, 'Unable to get access token. Please check your credentials.')); - else resolve(body.access_token); + else resolve(body); }); }) - .then((token) => { - return this.setAccessToken(session, `token ${token}`); + .then(({access_token, scope, token_type}) => { + return this.setAccessToken(session, `token ${access_token}`) + .then((token) => { + session.scope = scope; + session.token_type = token_type; + return token; + }); }); } else { return Promise.reject(new UnifileError(UnifileError.EACCES, 'Invalid credentials')); @@ -259,7 +265,7 @@

unifile-github.js

// Generate a random string for the state session.state = (+new Date() * Math.random()).toString(36).replace('.', ''); return Promise.resolve(this.oauthCallbackUrl - + '/authorize?' + APP_PERMISSION + + '/authorize?' + this.permission + '&client_id=' + this.clientId + '&state=' + session.state + (this.redirectUri ? '&redirect_uri=' + this.redirectUri : '')); @@ -435,7 +441,12 @@

unifile-github.js

writeFile(session, path, data) { const splitPath = getPathTokens(path); if(splitPath.length < 3) { - return Promise.reject(new UnifileError(UnifileError.ENOTSUP, 'This folder can only contain folders.')); + return Promise.reject(new UnifileError(UnifileError.ENOTSUP, ` + You are trying to add a file to a folder of Github which does not support files. + You can not add a file here because Github allows only folders at this level. + Please create a folder and put your file in it. + Github requires a folder to have at least 2 parents in order to accept files. + `)); } return this[createBlob](session, splitPath[0], data) .then((blob) => this[commitBlob](session, splitPath, blob)); @@ -446,7 +457,12 @@

unifile-github.js

if(splitPath.length < 3) { const stream = new PassThrough(); process.nextTick(() => { - stream.emit('error', new UnifileError(UnifileError.ENOTSUP, 'This folder can only contain folders.')); + stream.emit('error', new UnifileError(UnifileError.ENOTSUP, ` + You are trying to add a file to a folder of Github which does not support files. + You can not add a file here because Github allows only folders at this level. + Please create a folder and put your file in it. + Github requires a folder to have at least 2 parents in order to accept files. + `)); }); return stream; } @@ -1058,7 +1074,7 @@

unifile-github.js


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/unifile-remoteStorage.js.html b/docs/unifile-remoteStorage.js.html index fcc1440..d4d537f 100644 --- a/docs/unifile-remoteStorage.js.html +++ b/docs/unifile-remoteStorage.js.html @@ -341,7 +341,7 @@

unifile-remoteStorage.js


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/docs/unifile-sftp.js.html b/docs/unifile-sftp.js.html index 8d74217..f9b7feb 100644 --- a/docs/unifile-sftp.js.html +++ b/docs/unifile-sftp.js.html @@ -66,6 +66,10 @@

unifile-sftp.js

throw error; } +function protectPath(path) { + return path.length ? path : '/'; +} + /** * Service connector for {@link https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol|SFTP} */ @@ -141,7 +145,7 @@

unifile-sftp.js

readdir(session, path, sftpSession) { const sftp = sftpSession ? new SFTPClient() : new SFTPClient(session); - return sftp.ls(path, sftpSession) + return sftp.ls(protectPath(path), sftpSession) .catch(parseError) .then((directory) => { if(!directory.entries) return Promise.reject('Target is not a directory'); @@ -163,7 +167,7 @@

unifile-sftp.js

stat(session, path, sftpSession) { const sftp = sftpSession ? new SFTPClient() : new SFTPClient(session); - return sftp.stat(path, sftpSession) + return sftp.stat(protectPath(path), sftpSession) .catch(parseError) .then((entry) => { const filename = entry.path.split('/').pop(); @@ -327,7 +331,7 @@

unifile-sftp.js


- Documentation generated by JSDoc 3.5.5 on Mon Oct 08 2018 19:46:35 GMT+0200 (Romance Daylight Time) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Wed Nov 06 2019 16:44:41 GMT+0100 (Central European Standard Time) using the docdash theme.
diff --git a/package-lock.json b/package-lock.json index 69b4c36..33516f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "unifile", - "version": "2.0.6", + "version": "2.0.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 81cb74a..d01f015 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unifile", "description": "Library to provide a unified API, mirroring Fs, for cloud storage services. ", - "version": "2.0.7", + "version": "2.0.8", "author": "Jean-Baptiste Richardet (https://github.com/JbIPS)", "contributors": [ "Alex Hoyau (https://lexoyo.me/)"