mirror of
https://github.com/lovell/sharp.git
synced 2025-07-10 02:50:15 +02:00
Attempt to remove temp file after install #331
This commit is contained in:
parent
a0e034a9e9
commit
0ffa1e72d0
16
binding.js
16
binding.js
@ -25,7 +25,7 @@ var isFile = function(file) {
|
||||
return exists;
|
||||
};
|
||||
|
||||
var unpack = function(tarPath) {
|
||||
var unpack = function(tarPath, done) {
|
||||
var extractor = tar.Extract({
|
||||
path: __dirname
|
||||
});
|
||||
@ -34,6 +34,9 @@ var unpack = function(tarPath) {
|
||||
if (!isFile(vipsHeaderPath)) {
|
||||
error('Could not unpack ' + tarPath);
|
||||
}
|
||||
if (typeof done === 'function') {
|
||||
done();
|
||||
}
|
||||
});
|
||||
fs.createReadStream(tarPath).on('error', error)
|
||||
.pipe(zlib.Unzip())
|
||||
@ -73,10 +76,15 @@ module.exports.download_vips = function() {
|
||||
if (isFile(tarPath)) {
|
||||
unpack(tarPath);
|
||||
} else {
|
||||
// Download
|
||||
tarPath = path.join(tmp, tarFilename);
|
||||
// Download to per-process temporary file
|
||||
tarPath = path.join(tmp, process.pid + '-' + tarFilename);
|
||||
var tmpFile = fs.createWriteStream(tarPath).on('finish', function() {
|
||||
unpack(tarPath);
|
||||
unpack(tarPath, function() {
|
||||
// Attempt to remove temporary file
|
||||
try {
|
||||
fs.unlinkSync(tarPath);
|
||||
} catch (err) {}
|
||||
});
|
||||
});
|
||||
var options = {
|
||||
url: distBaseUrl + tarFilename
|
||||
|
@ -16,6 +16,10 @@
|
||||
[#326](https://github.com/lovell/sharp/issues/326)
|
||||
[@c0decafe](https://github.com/c0decafe)
|
||||
|
||||
* Attempt to remove temporary file after installation.
|
||||
[#331](https://github.com/lovell/sharp/issues/331)
|
||||
[@dtoubelis](https://github.com/dtoubelis)
|
||||
|
||||
#### v0.12.1 - 12<sup>th</sup> December 2015
|
||||
|
||||
* Allow use of SIMD vector instructions (via liborc) to be toggled on/off.
|
||||
|
Loading…
x
Reference in New Issue
Block a user