Commit f5212323 authored by nano's avatar nano

only one arira2 socket channel

parent c6a497f9
This diff is collapsed.
...@@ -75,12 +75,13 @@ export async function bundle(...args) { ...@@ -75,12 +75,13 @@ export async function bundle(...args) {
const fullHash = await caculateSHA256(filePath); const fullHash = await caculateSHA256(filePath);
const fullSize = (await fs.statAsync(filePath)).size; const fullSize = (await fs.statAsync(filePath)).size;
let fullPath = path.join(path.dirname(filePath), `${fullHash}.tar.gz`); let fullPath = path.join(dist_path, `${fullHash}.tar.gz`);
await fs.renameAsync(filePath, fullPath); await fs.renameAsync(filePath, fullPath);
await fs.removeAsync(uploadFile_path);
await fs.removeAsync(package_path);
return { return {
uploadFilePath: uploadFile_path,
pckagePath: package_path,
distPath: dist_path, distPath: dist_path,
files: Array.from(files.values()), files: Array.from(files.values()),
archives: Array.from(archives.values()), archives: Array.from(archives.values()),
......
...@@ -14,6 +14,11 @@ import config from '../../config'; ...@@ -14,6 +14,11 @@ import config from '../../config';
import {UploadOSS} from '../utils'; import {UploadOSS} from '../utils';
import Router = require('koa-router'); import Router = require('koa-router');
const downloader = new Aria2;
downloader.open();
const checkFilePath = async (file) => { const checkFilePath = async (file) => {
if (['.gz', '.rar', '.zip', '.7z'].indexOf(path.extname(file.path)) === -1) { if (['.gz', '.rar', '.zip', '.7z'].indexOf(path.extname(file.path)) === -1) {
console.log(file); console.log(file);
...@@ -148,15 +153,12 @@ const uploadPackageUrl = async (ctx: Context) => { ...@@ -148,15 +153,12 @@ const uploadPackageUrl = async (ctx: Context) => {
} }
// testUrl: https://r.my-card.in/release/dist/0c16a3ecb115fd7cf575ccdd64f62a8f3edc635b087950e4ed4f3f781972bbfd.tar.gz // testUrl: https://r.my-card.in/release/dist/0c16a3ecb115fd7cf575ccdd64f62a8f3edc635b087950e4ed4f3f781972bbfd.tar.gz
const downloader = new Aria2;
let pack = await mongodb.Packages.findOne({_id: toObjectID(ctx.request.body._id)}); let pack = await mongodb.Packages.findOne({_id: toObjectID(ctx.request.body._id)});
if (!pack) { if (!pack) {
return ctx.throw(400, 'pack not exists'); return ctx.throw(400, 'pack not exists');
} }
await downloader.open();
downloader.onDownloadStart = async () => { downloader.onDownloadStart = async () => {
pack!.status = 'uploading'; pack!.status = 'uploading';
await pack!.save(); await pack!.save();
...@@ -183,8 +185,6 @@ const uploadPackageUrl = async (ctx: Context) => { ...@@ -183,8 +185,6 @@ const uploadPackageUrl = async (ctx: Context) => {
// 上传完,干掉本地目录 // 上传完,干掉本地目录
await fs.removeAsync(bundled.distPath); await fs.removeAsync(bundled.distPath);
await fs.removeAsync(bundled.pckagePath);
await fs.removeAsync(bundled.uploadFilePath);
} catch (e) { } catch (e) {
console.trace(e); console.trace(e);
pack!.status = 'failed'; pack!.status = 'failed';
......
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