File tree 1 file changed +22
-8
lines changed
integration-tests/cache-resilience
1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const v8 = require(`v8`)
3
3
const glob = require ( `glob` )
4
4
const path = require ( `path` )
5
5
const _ = require ( `lodash` )
6
+ const { open } = require ( `lmdb-store` )
6
7
7
8
const { saveState } = require ( `gatsby/dist/redux/save-state` )
8
9
@@ -16,17 +17,30 @@ const getDiskCacheSnapshot = () => {
16
17
const plugins = getAllPlugins ( )
17
18
18
19
const snapshot = { }
19
- plugins . forEach ( pluginName => {
20
- const cacheDirectory = path . join ( __dirname , `.cache` , `caches` , pluginName )
20
+ let store
21
+ try {
22
+ store = open ( {
23
+ name : `root` ,
24
+ path : path . join ( process . cwd ( ) , `.cache/caches-lmdb` ) ,
25
+ compression : true ,
26
+ maxDbs : 200 ,
27
+ } )
28
+ plugins . forEach ( pluginName => {
29
+ const pluginDb = store . openDB ( {
30
+ name : pluginName ,
31
+ encoding : `json` ,
32
+ } )
21
33
22
- const files = glob . sync ( path . join ( cacheDirectory , `**` ) , {
23
- nodir : true ,
34
+ snapshot [ pluginName ] = Array . from ( pluginDb . getKeys ( { snapshot : false } ) )
24
35
} )
36
+ } catch ( e ) {
37
+ console . error ( e )
38
+ } finally {
39
+ if ( store ) {
40
+ store . close ( )
41
+ }
42
+ }
25
43
26
- snapshot [ pluginName ] = files . map ( absolutePath =>
27
- path . relative ( cacheDirectory , absolutePath )
28
- )
29
- } )
30
44
return snapshot
31
45
}
32
46
You can’t perform that action at this time.
0 commit comments