Skip to content

Commit

Permalink
Revert configurable LMDBCache FS
Browse files Browse the repository at this point in the history
`LMDBCache` is only used when the FS is `NodeFS` anyway.
  • Loading branch information
lettertwo committed Nov 2, 2021
1 parent 9fa5e09 commit 6c88b5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 8 additions & 14 deletions packages/core/cache/src/LMDBCache.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
// @flow strict-local
import type {Readable} from 'stream';
import type {FilePath} from '@parcel/types';
import type {FileSystem} from '@parcel/fs';
import type {Cache} from './types';

import path from 'path';
import {
serialize,
deserialize,
prepareForSerialization,
registerSerializableClass,
} from '@parcel/core';
import {serialize, deserialize, registerSerializableClass} from '@parcel/core';
import {NodeFS} from '@parcel/fs';
import {blobToStream, bufferStream} from '@parcel/utils';
// flowlint-next-line untyped-import:off
import packageJson from '../package.json';
// $FlowFixMe
import lmdb from 'lmdb-store';

export class LMDBCache implements Cache {
fs: FileSystem;
fs: NodeFS;
dir: FilePath;
// $FlowFixMe
store: any;

constructor(fs: FileSystem, cacheDir: FilePath) {
this.fs = fs;
constructor(cacheDir: FilePath) {
this.fs = new NodeFS();
this.dir = cacheDir;

this.store = lmdb.open(cacheDir, {
Expand All @@ -38,15 +33,14 @@ export class LMDBCache implements Cache {
return Promise.resolve();
}

serialize(): {|fs: FileSystem, dir: FilePath|} {
serialize(): {|dir: FilePath|} {
return {
fs: prepareForSerialization(this.fs),
dir: this.dir,
};
}

static deserialize(opts: {|fs: FileSystem, dir: FilePath|}): LMDBCache {
return new LMDBCache(opts.fs, opts.dir);
static deserialize(opts: {|dir: FilePath|}): LMDBCache {
return new LMDBCache(opts.dir);
}

has(key: string): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/resolveOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default async function resolveOptions(
let cache =
initialOptions.cache ??
(outputFS instanceof NodeFS
? new LMDBCache(outputFS, cacheDir)
? new LMDBCache(cacheDir)
: new FSCache(outputFS, cacheDir));

let mode = initialOptions.mode ?? 'development';
Expand Down

0 comments on commit 6c88b5d

Please sign in to comment.