Commit 205b8fd2 authored by nano's avatar nano

fix

parent c5346430
Pipeline #4714 failed with stages
......@@ -39,7 +39,7 @@ async function createPackage(app) {
});
}
async function createYgoproPackage(app) {
async function createCustomPackage(app) {
return await axios.post(config.new_package, {
id: uuid.v1(),
appId: app.id,
......@@ -64,8 +64,9 @@ async function updatePackage(app, pack) {
}
async function updateYogoproPackage(app, pack) {
let metalink = `${app.id}-${pack.platforms[0]}-${pack.locales[0]}`.replace('osx', 'darwin');
async function updateCustomPackage(app, pack) {
let metalink = `${app.id}-${pack.platforms[0]}`.replace('osx', 'darwin');
console.log(config.old_metalinks(metalink));
let { data } = await axios.get(config.old_metalinks(metalink));
const xml = new XmlDocument(data);
const rawUrl = xml.valueWithPath('file.url');
......@@ -86,16 +87,26 @@ async function handleYgopro(app) {
app.platforms = [platform];
app.locales = [locale];
console.log('正在处理yogopro', app.platforms, app.locales);
let { data } = await createYgoproPackage(app);
await updateYogoproPackage(app, data);
await wait(180000);
let { data } = await createCustomPackage(app);
await updateCustomPackage(app, data);
// await wait(180000);
} catch (e) {
console.log(e.response.data);
console.log(e);
}
}
}
}
async function handleDesume(app) {
for (let platform of platforms) {
app.platforms = [platform];
app.locales = locales;
console.log('正在处理desume', app.platforms, app.locales);
let { data } = await createCustomPackage(app);
await updateCustomPackage(app, data);
}
}
async function createApp(app) {
return await axios.post(config.new_app(app.id), {
id: app.id,
......@@ -156,7 +167,7 @@ async function main() {
});
for (let app of data) {
if (!['desmume', 'test'].includes(app['id']) && !apps[app['id']]) {
if (!['test'].includes(app['id']) && !apps[app['id']]) {
await createApp(app);
}
}
......@@ -179,10 +190,16 @@ async function main() {
// await updatePackage(app, data);
// }
if (app['id'] == 'ygopro') {
// if (app['id'] == 'ygopro') {
// await updateApp(app);
// await handleYgopro(app);
// }
if (app['id'] == 'desmume') {
await updateApp(app);
handleYgopro(app);
await handleDesume(app);
}
} catch (e) {
console.log(e.response.data);
......
......@@ -104,37 +104,43 @@ export const UploadPackage = async (ctx: Context) => {
file.on('close', async () => {
try {
pack!.status = 'uploading';
await pack!.save();
resolve(pack!);
await queue.run(async (ctx, next) => {
try {
pack!.status = 'uploading';
await pack!.save();
resolve(pack!);
// 上传完, 打包
let bundled;
// 上传完, 打包
let bundled;
await queue.run(async (ctx, next) => {
bundled = await bundle(filename);
this.next();
});
// 打包完,上传阿里云
await UploadOSS(bundled.distPath);
// 打包完,上传阿里云
await UploadOSS(bundled.distPath);
Object.assign(pack, bundled);
pack!.status = 'uploaded';
await mongodb.Packages.update({ id: pack!.id }, { $set: { status: 'deprecated' } }, { multi: true });
await pack!.save();
Object.assign(pack, bundled);
pack!.status = 'uploaded';
// 上传完,干掉本地目录
await fs.removeAsync(bundled.archivePath);
await mongodb.Packages.update({ id: pack!.id }, { $set: { status: 'deprecated' } }, { multi: true });
await pack!.save();
// 上传完,干掉本地目录
await fs.removeAsync(bundled.archivePath);
} catch (e) {
pack!.status = 'failed';
await pack!.save();
console.log(e);
}
next();
});
} catch (e) {
pack!.status = 'failed';
await pack!.save();
console.log(e);
}
});
file.on('error', async (error) => {
......@@ -181,33 +187,37 @@ const uploadPackageUrl = async (ctx: Context) => {
const [file] = files;
const [url] = file.uris;
if (ctx.request.body.url == url.uri) {
try {
await checkFilePath(file);
// 打包
let bundled;
await queue.run(async (ctx, next) => {
bundled = await bundle(path.basename(file.path));
next();
});
await queue.run(async (ctx, next) => {
try {
await checkFilePath(file);
// 打包完, 上传阿里云
await UploadOSS(bundled.distPath);
// 打包
const bundled = await bundle(path.basename(file.path));
Object.assign(pack, bundled);
pack!.status = 'uploaded';
await UploadOSS(bundled.distPath);
Object.assign(pack, bundled);
pack!.status = 'uploaded';
await mongodb.Packages.update({ id: pack!.id }, { $set: { status: 'deprecated' } }, { multi: true });
await pack!.save();
// 上传完,干掉本地目录
await fs.removeAsync(bundled.archivePath);
} catch (e) {
console.trace(e);
pack!.status = 'failed';
await pack!.save();
}
next();
});
// 打包完, 上传阿里云
await mongodb.Packages.update({ id: pack!.id }, { $set: { status: 'deprecated' } }, { multi: true });
await pack!.save();
// 上传完,干掉本地目录
await fs.removeAsync(bundled.archivePath);
} catch (e) {
console.trace(e);
pack!.status = 'failed';
await pack!.save();
}
await downloader.close();
}
};
......
......@@ -9,7 +9,7 @@ import config from './config';
async function test_checksums() {
const apps: any[] = (await (await fetch(config.new_apps_json)).json())
.filter(i => !['ygopro', 'desmume'].includes(i.id)); // 排除 ygopro 和 desmume
// .filter(i => !['ygopro', 'desmume'].includes(i.id)); // 排除 ygopro 和 desmume
let oldMaps = new Set();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment