Skip to content

Commit

Permalink
Merge pull request #103 from JarvusInnovations/develop
Browse files Browse the repository at this point in the history
Release: v0.22.2
  • Loading branch information
themightychris committed Aug 20, 2022
2 parents 73cb93c + 676d353 commit fe9cb6c
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions backend/lib/Sheet.js
@@ -1,5 +1,5 @@
const path = require('path');
const v8 = require('v8');
// const v8 = require('v8');
const vm = require('vm');
const sortKeys = require('sort-keys');
const TOML = require('@iarna/toml');
Expand Down Expand Up @@ -40,7 +40,7 @@ class Sheet extends Configurable
}
}

#recordCache;
// #recordCache;

constructor ({ workspace, name, dataTree = null, configPath = null }) {
if (!workspace) {
Expand All @@ -57,7 +57,7 @@ class Sheet extends Configurable
this.configPath = configPath || `.gitsheets/${name}.toml`;
this.dataTree = dataTree || workspace.root;

this.#recordCache = new Map();
// this.#recordCache = new Map();

Object.freeze(this);
}
Expand Down Expand Up @@ -116,22 +116,28 @@ class Sheet extends Configurable
}

async readRecord (blob, path = null) {
const cache = this.#recordCache.get(blob.hash);
/**
* caching is disabled for now, because v8.serialize doesn't
* preserve the custom Date classes that iarna/toml uses to
* preserve extended date types
*/

// const cache = this.#recordCache.get(blob.hash);

let record;

if (cache) {
record = v8.deserialize(cache);
} else {
const toml = await blob.read();
// if (cache) {
// record = v8.deserialize(cache);
// } else {
const toml = await blob.read();

try {
record = TOML.parse(toml);
} catch (err) {
err.file = path;
throw err;
}
try {
record = TOML.parse(toml);
} catch (err) {
err.file = path;
throw err;
}
// }

// annotate with gitsheets keys
record[RECORD_SHEET_KEY] = this.name;
Expand All @@ -140,9 +146,9 @@ class Sheet extends Configurable
}

// fill cache
if (!cache) {
this.#recordCache.set(blob.hash, v8.serialize(record));
}
// if (!cache) {
// this.#recordCache.set(blob.hash, toml);
// }

return record;
}
Expand Down

0 comments on commit fe9cb6c

Please sign in to comment.