fix s3path incorrectly includes bucketid

This commit is contained in:
SrGooglo 2025-04-08 19:48:20 +00:00
parent a8f7dc3c13
commit 564cecd2f0
3 changed files with 117 additions and 110 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@comty/server",
"version": "1.30.2@alpha",
"version": "1.30.3@alpha",
"license": "ComtyLicense",
"private": true,
"workspaces": [

View File

@ -1,8 +1,6 @@
{
"name": "marketplace",
"version": "0.60.2",
"dependencies": {
"@octokit/rest": "^19.0.7",
"7zip-min": "^1.4.4",
"backblaze-b2": "^1.7.0",
"sucrase": "^3.32.0",

View File

@ -17,7 +17,9 @@ async function uploadFolderToB2(bucketId, folderPath, b2Directory) {
await uploadFiles(fullPath)
} else {
const fileData = fs.readFileSync(fullPath)
const b2FileName = path.join(b2Directory, path.relative(folderPath, fullPath)).replace(/\\/g, '/')
const b2FileName = path
.join(b2Directory, path.relative(folderPath, fullPath))
.replace(/\\/g, "/")
console.log(`Uploading ${b2FileName}...`)
@ -38,9 +40,9 @@ async function uploadFolderToB2(bucketId, folderPath, b2Directory) {
}
await uploadFiles(folderPath)
console.log('All files uploaded successfully.')
console.log("All files uploaded successfully.")
} catch (error) {
console.error('Error uploading folder:', error)
console.error("Error uploading folder:", error)
}
}
@ -61,10 +63,13 @@ export default {
const { user_id } = req.auth.session
const registryId = `${user_id}/${pkg.name}@${pkg.version}`
const s3Path = `${process.env.B2_BUCKET_ID}/extensions/${pkg.name}/${pkg.version}`
const assetsUrl = `https://${process.env.B2_CDN_ENDPOINT}/${process.env.B2_BUCKET}/${s3Path}`
const s3Path = `extensions/${pkg.name}/${pkg.version}`
const workPath = path.resolve(global.cache.constructor.cachePath, String(Date.now()), registryId)
const workPath = path.resolve(
global.cache.constructor.cachePath,
String(Date.now()),
registryId,
)
const pkgPath = path.resolve(workPath, "pkg")
const bundlePath = path.resolve(workPath, "bundle.7z")
@ -80,7 +85,7 @@ export default {
let extensionRegistry = await Extension.findOne({
user_id: user_id,
registryId: registryId,
version: pkg.version
version: pkg.version,
})
if (extensionRegistry) {
@ -100,7 +105,10 @@ export default {
await new Promise((resolve, reject) => {
sevenzip.unpack(bundlePath, pkgPath, (error) => {
if (error) {
fs.promises.rm(workPath, { recursive: true, force: true })
fs.promises.rm(workPath, {
recursive: true,
force: true,
})
reject(error)
} else {
resolve()
@ -112,6 +120,7 @@ export default {
fs.promises.rm(workPath, { recursive: true, force: true })
const assetsUrl = `https://${process.env.B2_CDN_ENDPOINT}/${process.env.B2_BUCKET}/${s3Path}`
extensionRegistry = await Extension.create({
user_id: user_id,
@ -129,5 +138,5 @@ export default {
fs.promises.rm(workPath, { recursive: true, force: true })
throw error
}
}
},
}