sync-disk-cache
Advanced tools
Comparing version 1.3.3 to 1.3.4
10
index.js
@@ -7,2 +7,3 @@ 'use strict'; | ||
var writeFile = fs.writeFileSync; | ||
var renameFile = fs.renameSync; | ||
var mkdirp = require('mkdirp').sync; | ||
@@ -183,2 +184,4 @@ var rimraf = require('rimraf').sync; | ||
var MAX_DIGITS = Math.pow(10, (Number.MAX_SAFE_INTEGER + '').length); | ||
/* | ||
@@ -195,9 +198,11 @@ * @public | ||
debug('set : %s', filePath); | ||
var random = Math.random() * MAX_DIGITS; | ||
var tmpfile = filePath + '.tmp.' + random; | ||
try { | ||
writeFile(filePath, this.compress(value), mode); | ||
writeFile(tmpfile, this.compress(value), mode); | ||
} catch (e) { | ||
if (e.code === 'ENOENT') { | ||
mkdirp(path.dirname(filePath), mode); | ||
writeFile(filePath, this.compress(value), mode); | ||
writeFile(tmpfile, this.compress(value), mode); | ||
} else { | ||
@@ -207,2 +212,3 @@ throw e; | ||
} | ||
renameFile(tmpfile, filePath); | ||
chmod(filePath, mode.mode); | ||
@@ -209,0 +215,0 @@ |
{ | ||
"name": "sync-disk-cache", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "sync disk cache", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -59,4 +59,16 @@ # sync-disk-cache [![Build status](https://ci.appveyor.com/api/projects/status/fjm3xhxs492x32wp?svg=true)](https://ci.appveyor.com/project/embercli/sync-disk-cache) [![Build Status](https://travis-ci.org/stefanpenner/sync-disk-cache.svg)](https://travis-ci.org/stefanpenner/sync-disk-cache) | ||
## HELP!...my TMP dir is growing unbounded! | ||
### description | ||
In general most OS distributions come with cron like tasks, which purge unused files in `$TMPDIR`. For example, ubuntu typically uses `tmpreaper` and macOS uses various tasks in `/etc/periodic/*`. | ||
## options | ||
If your OS distribution does not provide such a cleanup mechanism: | ||
a) We stronglly recommend utilizing one, as other sync-disk-cache is not alone in rely on this behavior | ||
b) If that is not possible, we recommend changing your `$TMPDIR` to something project specific and manually purging it. | ||
## License | ||
Licensed under the MIT License, Copyright 2015 Stefan Penner |
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
10518
264
74