Page MenuHomePhabricator

D4101.id13009.diff
No OneTemporary

D4101.id13009.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
@@ -8,18 +8,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, 7:22 AM (18 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2517920
Default Alt Text
D4101.id13009.diff (826 B)

Event Timeline