New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@koopjs/filesystem-s3

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koopjs/filesystem-s3 - npm Package Compare versions

Comparing version

to
1.2.5

.eslintrc.js

5

CHANGELOG.MD

@@ -5,2 +5,6 @@ # Change Log

## [1.2.5] - 2017-11-29
### Fixed
* Refactor createWriteStream to fix memory leak with Highland
## [1.2.4] - 2017-04-13

@@ -52,2 +56,3 @@ ### Fixed

[1.2.5]: https://github.com/koopjs/koop-filesystem-s3/compare/v1.2.4..v1.2.5
[1.2.4]: https://github.com/koopjs/koop-filesystem-s3/compare/v1.2.3..v1.2.4

@@ -54,0 +59,0 @@ [1.2.3]: https://github.com/koopjs/koop-filesystem-s3/compare/v1.2.3..v1.2.2

80

dist/index.js

@@ -10,3 +10,3 @@ var config = require('config')

}
var request = require('request').defaults({timeout: timeout})
var request = require('request').defaults({ timeout: timeout })
var zlib = require('zlib')

@@ -60,27 +60,27 @@ var Stats = require('s3fs/lib/Stats')

}
var decompress = (typeof options.gunzip === 'boolean' && !options.gunzip) ? _() : gunzip()
var decompress = typeof options.gunzip === 'boolean' && !options.gunzip ? _() : gunzip()
var url = this.s3.getSignedUrl('getObject', params)
var output = _()
request(url)
.on('error', function (e) {
if (!locked) { output.emit('error', e) }
locked = true
})
.on('response', function (response) {
if (response.statusCode !== 200) {
var error = new Error('Unable to retrieve file')
error.code = response.statusCode
if (!locked) { output.emit('error', error) }
.on('error', function (e) {
if (!locked) { output.emit('error', e) }
locked = true
} else if (response.headers['content-length'] < 1) {
if (!locked) { output.emit('error', new Error('Empty file')) }
})
.on('response', function (response) {
if (response.statusCode !== 200) {
var error = new Error('Unable to retrieve file')
error.code = response.statusCode
if (!locked) { output.emit('error', error) }
locked = true
} else if (response.headers['content-length'] < 1) {
if (!locked) { output.emit('error', new Error('Empty file')) }
locked = true
}
})
.pipe(decompress)
.on('error', function (e) {
if (!locked) { output.emit('error', e) }
locked = true
}
})
.pipe(decompress)
.on('error', function (e) {
if (!locked) { output.emit('error', e) }
locked = true
})
.pipe(output)
})
.pipe(output)

@@ -99,21 +99,27 @@ return output

Filesystem.prototype.createWriteStream = function createWriteStream (name, options) {
var this$1 = this;
var upload
var aborted = false
var input = _()
var through = _()
input.on('data', function (chunk) {
through.write(chunk)
var pipeline = _.pipeline(function (stream) {
var params = this$1.s3Params(this$1.bucket, name, options)
var uploadStream = (params.Body = stream.pipe(zlib.createGzip()))
upload = this$1.s3.upload(params, function (err, data) {
if (err && !aborted) {
pipeline.emit('error', err)
} else if (!err) {
pipeline.emit('finish')
}
})
return uploadStream
})
input.end = function (chunk) {
if (chunk && !through._nil_pushed) { through.write(chunk) }
if (!through._nil_pushed) { through.write(_.nil) }
pipeline.end = function (chunk) {
if (chunk && !pipeline._nil_pushed) { pipeline.write(chunk) }
if (!pipeline._nil_pushed) { pipeline.write(_.nil) }
}
var params = this.s3Params(this.bucket, name, options)
params.Body = through.pipe(zlib.createGzip())
var upload = this.s3.upload(params, function (err, data) {
if (err && !aborted) { input.emit('error', err) }
else if (!err) { input.emit('finish') }
})
input.abort = function () {
pipeline.abort = function () {
aborted = true

@@ -123,3 +129,3 @@ upload.abort()

return input
return pipeline
};

@@ -126,0 +132,0 @@

{
"name": "@koopjs/filesystem-s3",
"version": "1.2.4",
"version": "1.2.5",
"description": "An AWS S3-backed filesystem plugin for Koop",
"main": "dist/index.js",
"scripts": {
"test": "standard src/ && npm run compile && NODE_ENV=test tape test/*.js | tap-spec",
"test": "standard src/ && NODE_ENV=test tape test/*.js | tap-spec",
"compile": "buble -i src -o dist"

@@ -14,9 +14,3 @@ },

},
"keywords": [
"koop",
"s3",
"aws",
"fs",
"files"
],
"keywords": ["koop", "s3", "aws", "fs", "files"],
"author": "Daniel Fenton <dfenton@esri.com>",

@@ -29,3 +23,3 @@ "license": "Apache-2.0",

"devDependencies": {
"buble": "^0.15.2",
"buble": "^0.18.0",
"nock": "^9.0.13",

@@ -32,0 +26,0 @@ "standard": "^10.0.0",

Sorry, the diff of this file is not supported yet