Skip to content

Commit

Permalink
DOP-1078: Correctly write intersphinx inventory (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored May 7, 2020
1 parent 5232d2a commit c804fc4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ exports.createPages = async ({ actions }) => {

// Save files in the static_files field of metadata document, including intersphinx inventories
if (metadata.static_files) {
saveStaticFiles(metadata.static_files);
await saveStaticFiles(metadata.static_files);
}

return new Promise((resolve, reject) => {
Expand Down
8 changes: 2 additions & 6 deletions src/utils/setup/save-asset-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,18 @@ const saveFile = async (file, data) => {
// Write all assets to static directory
const saveAssetFiles = async (assets, stitchClient) => {
if (assets.length) {
const promises = [];
const assetQuery = { _id: { $in: assets } };
const assetDataDocuments = await stitchClient.callFunction('fetchDocuments', [
database,
ASSETS_COLLECTION,
assetQuery,
]);
assetDataDocuments.forEach(({ filename, data: { buffer } }) => {
promises.push(saveFile(filename, buffer));
});
await Promise.all(promises);
await Promise.all(assetDataDocuments.map(({ filename, data: { buffer } }) => saveFile(filename, buffer)));
}
};

const saveStaticFiles = async staticFiles => {
Object.entries(staticFiles).forEach(([file, data]) => saveFile(file, data));
await Promise.all(Object.entries(staticFiles).map(([file, data]) => saveFile(file, data.buffer)));
};

module.exports = { saveAssetFiles, saveStaticFiles };

1 comment on commit c804fc4

@skerschb
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Please sign in to comment.