From 86cf9207b00c8bc53267f7c81ff7ae10e37163fb Mon Sep 17 00:00:00 2001 From: Peter van der Zee <209817+pvdz@users.noreply.github.com> Date: Thu, 9 Apr 2020 11:00:16 +0200 Subject: [PATCH] fix(gatsby): Use tmp dir for tmp redux cache folder (#22959) --- packages/gatsby/src/redux/persist.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby/src/redux/persist.ts b/packages/gatsby/src/redux/persist.ts index 7bc4a0cba0c0c..c7a5d45bb8a37 100644 --- a/packages/gatsby/src/redux/persist.ts +++ b/packages/gatsby/src/redux/persist.ts @@ -1,4 +1,5 @@ import path from "path" +import os from "os" import v8 from "v8" import { existsSync, @@ -139,7 +140,7 @@ export function writeToCache(contents: ICachedReduxState): void { // Note: this should be a transactional operation. So work in a tmp dir and // make sure the cache cannot be left in a corruptable state due to errors. - const tmpDir = mkdtempSync(`reduxcache`) // linux / windows + const tmpDir = mkdtempSync(path.join(os.tmpdir(), `reduxcache`)) // linux / windows prepareCacheFolder(tmpDir, contents)