sync-disk-cache
Advanced tools
+8
-2
@@ -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 @@ |
+1
-1
| { | ||
| "name": "sync-disk-cache", | ||
| "version": "1.3.3", | ||
| "version": "1.3.4", | ||
| "description": "sync disk cache", | ||
@@ -5,0 +5,0 @@ "files": [ |
+12
-0
@@ -59,4 +59,16 @@ # sync-disk-cache [](https://ci.appveyor.com/project/embercli/sync-disk-cache) [](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 |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10518
8.08%264
1.93%74
19.35%