File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
packages/gatsby/src/utils Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ describeWhenLMDB(`cache-lmdb`, () => {
1313
1414 beforeAll ( async ( ) => {
1515 const { default : GatsbyCacheLmdb } = await import ( `../cache-lmdb` )
16- cache = new GatsbyCacheLmdb ( { name : `__test__` } )
16+ cache = new GatsbyCacheLmdb ( { name : `__test__` } ) . init ( )
1717 const fileDir = path . join (
1818 process . cwd ( ) ,
1919 `.cache/caches-lmdb-${ process . env . JEST_WORKER_ID } `
Original file line number Diff line number Diff line change 11import { open , RootDatabase , Database } from "lmdb-store"
2+ import fs from "fs-extra"
23import path from "path"
34
45// Since the regular GatsbyCache saves to "caches" this should be "caches-lmdb"
@@ -16,9 +17,17 @@ export default class GatsbyCacheLmdb {
1617 private static store
1718 private db : Database | undefined
1819 public readonly name : string
20+ // Needed for plugins that want to write data to the cache directory
21+ public readonly directory : string
1922
2023 constructor ( { name = `db` } : { name : string } ) {
2124 this . name = name
25+ this . directory = path . join ( process . cwd ( ) , `.cache/caches/${ name } ` )
26+ }
27+
28+ init ( ) : GatsbyCacheLmdb {
29+ fs . ensureDirSync ( this . directory )
30+ return this
2231 }
2332
2433 private static getStore ( ) : RootDatabase {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export const getCache = (name: string): GatsbyCache => {
88 if ( ! cache ) {
99 if ( isLmdbStore ( ) ) {
1010 const GatsbyCacheLmdb = require ( `./cache-lmdb` ) . default
11- cache = new GatsbyCacheLmdb ( { name } ) as GatsbyCache
11+ cache = new GatsbyCacheLmdb ( { name } ) . init ( ) as GatsbyCache
1212 } else {
1313 cache = new GatsbyCache ( { name } ) . init ( )
1414 }
You can’t perform that action at this time.
0 commit comments