Page MenuHomePhabricator

D4101.diff
No OneTemporary

D4101.diff

diff --git a/keyserver/src/utils/import-json.js b/keyserver/src/utils/import-json.js
--- a/keyserver/src/utils/import-json.js
+++ b/keyserver/src/utils/import-json.js
@@ -6,18 +6,21 @@
if (cached !== undefined) {
return cached;
}
+ const json = await getJSON(path);
+ if (!cachedJSON.has(path)) {
+ cachedJSON.set(path, json);
+ }
+ return cachedJSON.get(path);
+}
+
+async function getJSON<T>(path: string): Promise<?T> {
try {
// $FlowFixMe
const importedJSON = await import(`../../${path}`);
- if (!cachedJSON.has(path)) {
- cachedJSON.set(path, importedJSON.default);
- }
+ return importedJSON.default;
} catch {
- if (!cachedJSON.has(path)) {
- cachedJSON.set(path, null);
- }
+ return null;
}
- return cachedJSON.get(path);
}
export { importJSON };

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 6:18 AM (20 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2515985
Default Alt Text
D4101.diff (826 B)

Event Timeline