Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3276126
D4101.id13009.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
826 B
Referenced Files
None
Subscribers
None
D4101.id13009.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D4101: [keyserver] Extract getJSON from importJSON
Attached
Detach File
Event Timeline
Log In to Comment