1
0
Fork 0
mirror of synced 2024-06-27 18:40:42 +12:00

Remove log statement, batch uploads and remove unecessary conditional

This commit is contained in:
Andrew Kingston 2021-07-09 16:42:09 +01:00
parent dbac6d5988
commit efb0c60464
2 changed files with 18 additions and 31 deletions

View file

@ -313,9 +313,7 @@ const updateAppPackage = async (ctx, appPackage, appId) => {
// the locked by property is attached by server but generated from // the locked by property is attached by server but generated from
// Redis, shouldn't ever store it // Redis, shouldn't ever store it
if (newAppPackage.lockedBy) { delete newAppPackage.lockedBy
delete newAppPackage.lockedBy
}
return await db.put(newAppPackage) return await db.put(newAppPackage)
} }

View file

@ -34,10 +34,8 @@ const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..")
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
exports.backupClientLibrary = async appId => { exports.backupClientLibrary = async appId => {
let tmpManifestPath
let tmpClientPath
// Copy existing manifest to tmp // Copy existing manifest to tmp
let tmpManifestPath
try { try {
// Try to load the manifest from the new file location // Try to load the manifest from the new file location
tmpManifestPath = await retrieveToTmp( tmpManifestPath = await retrieveToTmp(
@ -60,26 +58,25 @@ exports.backupClientLibrary = async appId => {
} }
// Copy existing client lib to tmp // Copy existing client lib to tmp
tmpClientPath = await retrieveToTmp( const tmpClientPath = await retrieveToTmp(
ObjectStoreBuckets.APPS, ObjectStoreBuckets.APPS,
join(appId, "budibase-client.js") join(appId, "budibase-client.js")
) )
// Upload manifest as backup // Upload manifest and client library as backups
await upload({ const manifestUpload = upload({
bucket: ObjectStoreBuckets.APPS, bucket: ObjectStoreBuckets.APPS,
filename: join(appId, "manifest.json.bak"), filename: join(appId, "manifest.json.bak"),
path: tmpManifestPath, path: tmpManifestPath,
type: "application/json", type: "application/json",
}) })
const clientUpload = upload({
// Upload client library as backup
await upload({
bucket: ObjectStoreBuckets.APPS, bucket: ObjectStoreBuckets.APPS,
filename: join(appId, "budibase-client.js.bak"), filename: join(appId, "budibase-client.js.bak"),
path: tmpClientPath, path: tmpClientPath,
type: "application/javascript", type: "application/javascript",
}) })
await Promise.all([manifestUpload, clientUpload])
} }
/** /**
@ -99,13 +96,10 @@ exports.updateClientLibrary = async appId => {
// Load the bundled version in prod // Load the bundled version in prod
manifest = resolve(TOP_LEVEL_PATH, "client", "manifest.json") manifest = resolve(TOP_LEVEL_PATH, "client", "manifest.json")
client = resolve(TOP_LEVEL_PATH, "client", "budibase-client.js") client = resolve(TOP_LEVEL_PATH, "client", "budibase-client.js")
console.log(manifest)
console.log(client)
} }
// Upload latest component manifest // Upload latest manifest and client library
await streamUpload( const manifestUpload = streamUpload(
ObjectStoreBuckets.APPS, ObjectStoreBuckets.APPS,
join(appId, "manifest.json"), join(appId, "manifest.json"),
fs.createReadStream(manifest), fs.createReadStream(manifest),
@ -113,9 +107,7 @@ exports.updateClientLibrary = async appId => {
ContentType: "application/json", ContentType: "application/json",
} }
) )
const clientUpload = streamUpload(
// Upload latest component library
await streamUpload(
ObjectStoreBuckets.APPS, ObjectStoreBuckets.APPS,
join(appId, "budibase-client.js"), join(appId, "budibase-client.js"),
fs.createReadStream(client), fs.createReadStream(client),
@ -123,6 +115,7 @@ exports.updateClientLibrary = async appId => {
ContentType: "application/javascript", ContentType: "application/javascript",
} }
) )
await Promise.all([manifestUpload, clientUpload])
} }
/** /**
@ -132,34 +125,30 @@ exports.updateClientLibrary = async appId => {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
exports.revertClientLibrary = async appId => { exports.revertClientLibrary = async appId => {
let tmpManifestPath // Copy backups manifest to tmp directory
let tmpClientPath const tmpManifestPath = await retrieveToTmp(
// Copy backup manifest to tmp
tmpManifestPath = await retrieveToTmp(
ObjectStoreBuckets.APPS, ObjectStoreBuckets.APPS,
join(appId, "manifest.json.bak") join(appId, "manifest.json.bak")
) )
// Copy backup client lib to tmp // Copy backup client lib to tmp
tmpClientPath = await retrieveToTmp( const tmpClientPath = await retrieveToTmp(
ObjectStoreBuckets.APPS, ObjectStoreBuckets.APPS,
join(appId, "budibase-client.js.bak") join(appId, "budibase-client.js.bak")
) )
// Upload manifest backup // Upload backups as new versions
await upload({ const manifestUpload = upload({
bucket: ObjectStoreBuckets.APPS, bucket: ObjectStoreBuckets.APPS,
filename: join(appId, "manifest.json"), filename: join(appId, "manifest.json"),
path: tmpManifestPath, path: tmpManifestPath,
type: "application/json", type: "application/json",
}) })
const clientUpload = upload({
// Upload client library backup
await upload({
bucket: ObjectStoreBuckets.APPS, bucket: ObjectStoreBuckets.APPS,
filename: join(appId, "budibase-client.js"), filename: join(appId, "budibase-client.js"),
path: tmpClientPath, path: tmpClientPath,
type: "application/javascript", type: "application/javascript",
}) })
await Promise.all([manifestUpload, clientUpload])
} }