rotating-file-stream
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -7,2 +7,3 @@ "use strict"; | ||
var utils = require("./utils"); | ||
var zlib = require("zlib"); | ||
@@ -14,12 +15,25 @@ function compress(callback, tmp) { | ||
if(err) | ||
return callback(name, err); | ||
return callback(null, err); | ||
self.touch(name, function(err) { | ||
if(err) | ||
return callback(name, err); | ||
return callback(null, err); | ||
var done = function(err) { | ||
if(err) | ||
return callback(name, err); | ||
fs.unlink(tmp, callback.bind(null, name)); | ||
}; | ||
if(typeof self.options.compress == "function") | ||
self.external(tmp, name, callback.bind(null, name)); | ||
self.external(tmp, name, done); | ||
else | ||
throw new Error("Not implemented yet"); | ||
self.gzip(tmp, name, done); | ||
/* | ||
if(self.options.compress == "gzip") | ||
self.gzip(tmp, name, done); | ||
else | ||
throw new Error("Not implemented yet"); | ||
*/ | ||
}); | ||
@@ -87,2 +101,17 @@ }); | ||
function gzip(src, dst, callback) { | ||
var inp = fs.createReadStream(src); | ||
var out = fs.createWriteStream(dst); | ||
var zip = zlib.createGzip(); | ||
var files = [inp, out, zip]; | ||
for(var i in files) | ||
files[i].once("error", callback); | ||
out.once("finish", callback); | ||
inp.pipe(zip).pipe(out); | ||
} | ||
function touch(name, callback, retry) { | ||
@@ -111,3 +140,4 @@ var self = this; | ||
findName: findName, | ||
gzip: gzip, | ||
touch: touch | ||
}; |
{ | ||
"name": "rotating-file-stream", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "Opens a stream.Writable to a file rotated by interval and/or size. A logrotate alternative.", | ||
@@ -32,3 +32,3 @@ "engines": { | ||
"devDependencies": { | ||
"istanbul": "0.3.21", | ||
"istanbul": "0.3.22", | ||
"jshint": "2.8.0", | ||
@@ -35,0 +35,0 @@ "mocha": "2.3.3", |
@@ -24,8 +24,2 @@ # rotating-file-stream | ||
# under development | ||
__This package is currently under development.__ | ||
Please check the [TODO list](#todo) to be aware of what is missing. | ||
### Installation | ||
@@ -161,3 +155,2 @@ | ||
Following fixed strings are allowed to compress the files with internal libraries: | ||
* bzip | ||
* gzip | ||
@@ -266,9 +259,6 @@ | ||
### TODO | ||
* Internal compression gzip | ||
* Internal compression bzip | ||
### ChangeLog | ||
* 2015-10-07 - v0.1.0 | ||
* Internal gzip compression | ||
* 2015-10-06 - v0.0.5 | ||
@@ -275,0 +265,0 @@ * External compression |
@@ -89,3 +89,4 @@ "use strict"; | ||
if(typ == "string") { | ||
if(val != "bzip" && val != "gzip") | ||
//if(val != "bzip" && val != "gzip") | ||
if(val != "gzip") | ||
throw new Error("Don't know how to handle compression method: " + val); | ||
@@ -92,0 +93,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24641
492
275