1
0
Fork 0
mirror of synced 2024-06-21 11:51:00 +12:00

Merge branch 'feature/fs-removal' of github.com:Budibase/budibase into lab-day/lucene

This commit is contained in:
mike12345567 2021-03-25 21:56:18 +00:00
commit 8ae0e6bf15

View file

@ -13,6 +13,10 @@ const { ObjectStoreBuckets } = require("../../constants")
const uuid = require("uuid/v4")
const streamPipeline = promisify(stream.pipeline)
// use this as a temporary store of buckets that are being created
const STATE = {
bucketCreationPromises: {},
}
const CONTENT_TYPE_MAP = {
html: "text/html",
@ -81,13 +85,18 @@ exports.makeSureBucketExists = async (client, bucketName) => {
})
.promise()
} catch (err) {
// bucket doesn't exist create it
if (err.statusCode === 404) {
await client
const promises = STATE.bucketCreationPromises
if (promises[bucketName]) {
await promises[bucketName]
} else if (err.statusCode === 404) {
// bucket doesn't exist create it
promises[bucketName] = client
.createBucket({
Bucket: bucketName,
})
.promise()
await promises[bucketName]
delete promises[bucketName]
// public buckets are quite hidden in the system, make sure
// no bucket is set accidentally
if (PUBLIC_BUCKETS.includes(bucketName)) {