Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32176977
D4101.1765068936.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
826 B
Referenced Files
None
Subscribers
None
D4101.1765068936.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, Dec 7, 12:55 AM (7 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5841768
Default Alt Text
D4101.1765068936.diff (826 B)
Attached To
Mode
D4101: [keyserver] Extract getJSON from importJSON
Attached
Detach File
Event Timeline
Log In to Comment