Merge branch 'feature/fs-removal' of github.com:Budibase/budibase into lab-day/lucene
This commit is contained in:
commit
942214a54a
|
@ -13,6 +13,10 @@ const { ObjectStoreBuckets } = require("../../constants")
|
||||||
const uuid = require("uuid/v4")
|
const uuid = require("uuid/v4")
|
||||||
|
|
||||||
const streamPipeline = promisify(stream.pipeline)
|
const streamPipeline = promisify(stream.pipeline)
|
||||||
|
// use this as a temporary store of buckets that are being created
|
||||||
|
const STATE = {
|
||||||
|
bucketCreationPromises: {},
|
||||||
|
}
|
||||||
|
|
||||||
const CONTENT_TYPE_MAP = {
|
const CONTENT_TYPE_MAP = {
|
||||||
html: "text/html",
|
html: "text/html",
|
||||||
|
@ -81,13 +85,18 @@ exports.makeSureBucketExists = async (client, bucketName) => {
|
||||||
})
|
})
|
||||||
.promise()
|
.promise()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// bucket doesn't exist create it
|
const promises = STATE.bucketCreationPromises
|
||||||
if (err.statusCode === 404) {
|
if (promises[bucketName]) {
|
||||||
await client
|
await promises[bucketName]
|
||||||
|
} else if (err.statusCode === 404) {
|
||||||
|
// bucket doesn't exist create it
|
||||||
|
promises[bucketName] = client
|
||||||
.createBucket({
|
.createBucket({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
})
|
})
|
||||||
.promise()
|
.promise()
|
||||||
|
await promises[bucketName]
|
||||||
|
delete promises[bucketName]
|
||||||
// public buckets are quite hidden in the system, make sure
|
// public buckets are quite hidden in the system, make sure
|
||||||
// no bucket is set accidentally
|
// no bucket is set accidentally
|
||||||
if (PUBLIC_BUCKETS.includes(bucketName)) {
|
if (PUBLIC_BUCKETS.includes(bucketName)) {
|
||||||
|
|
Loading…
Reference in New Issue