diff --git a/packages/metro-cache/src/stores/FileStore.js b/packages/metro-cache/src/stores/FileStore.js index eb4a6ab153..a0639f27bb 100644 --- a/packages/metro-cache/src/stores/FileStore.js +++ b/packages/metro-cache/src/stores/FileStore.js @@ -25,7 +25,6 @@ class FileStore { constructor(options: Options) { this._root = options.root; - this._createDirs(); } async get(key: Buffer): Promise { @@ -72,7 +71,6 @@ class FileStore { clear() { this._removeDirs(); - this._createDirs(); } _getFilePath(key: Buffer): string { @@ -83,14 +81,6 @@ class FileStore { ); } - _createDirs() { - for (let i = 0; i < 256; i++) { - fs.mkdirSync(path.join(this._root, ('0' + i.toString(16)).slice(-2)), { - recursive: true, - }); - } - } - _removeDirs() { for (let i = 0; i < 256; i++) { fs.rmSync(path.join(this._root, ('0' + i.toString(16)).slice(-2)), { diff --git a/packages/metro-cache/src/stores/__tests__/FileStore-test.js b/packages/metro-cache/src/stores/__tests__/FileStore-test.js index 610a67e600..968f2a34c7 100644 --- a/packages/metro-cache/src/stores/__tests__/FileStore-test.js +++ b/packages/metro-cache/src/stores/__tests__/FileStore-test.js @@ -10,6 +10,8 @@ 'use strict'; +const {dirname} = require('path'); + describe('FileStore', () => { let FileStore; let fs; @@ -44,7 +46,7 @@ describe('FileStore', () => { const fileStore = new FileStore({root: '/root'}); const cache = Buffer.from([0xfa, 0xce, 0xb0, 0x0c]); const filePath = fileStore._getFilePath(cache); - + fs.mkdirSync(dirname(filePath), {recursive: true}); fs.writeFileSync(filePath, ''); expect(await fileStore.get(cache)).toEqual(null); });