Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JoCat committed Sep 12, 2023
1 parent 3b2b3e1 commit 31899e3
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 51 deletions.
74 changes: 37 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"type": "commonjs",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"types": "./dist/types/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
"types": "./dist/types/index.d.ts"
},
"scripts": {
"dev": "tsup --watch",
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"dependencies": {
"adm-zip": "^0.5.10",
"got": "^13.0.0",
"got": "^12.6.1",
"p-map": "^6.0.0"
}
}
2 changes: 2 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"compilerOptions": {
"declaration": true,
"declarationDir": "dist/types",
"declarationMap": true,
"emitDeclarationOnly": true,
"module": "ES2022",
"moduleResolution": "Bundler"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { defineConfig } from "tsup"
export default defineConfig({
entry: ["src/index.ts"],
format: ["esm", "cjs"],
target: "node18",
target: "node20",
sourcemap: true,
minify: true,
clean: true,
dts: true,
onSuccess: "tsc",
})
24 changes: 15 additions & 9 deletions packages/server/src/components/download/DownloadManagers/Mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ export class MirrorManager extends AbstractDownloadManager {
async downloadClient(fileName: string, clientName: string): Promise<void> {
const mirrors: string[] = this.configManager.config.mirrors;

const clientDirPath = resolve(StorageHelper.clientsDir, clientName);

try {
await mkdir(clientDirPath);
} catch (err) {
return LogHelper.error(this.langManager.getTranslate.DownloadManager.dirExist);
}

const mirror = mirrors.find(async (mirror) => {
await HttpHelper.existsResource(new URL(`${fileName}.zip`, mirror));
});
Expand All @@ -37,12 +29,26 @@ export class MirrorManager extends AbstractDownloadManager {
);
}

const clientDirPath = resolve(StorageHelper.clientsDir, clientName);

try {
await mkdir(clientDirPath);
} catch (err) {
return LogHelper.error(this.langManager.getTranslate.DownloadManager.dirExist);
}

LogHelper.info(this.langManager.getTranslate.DownloadManager.MirrorManager.client.download);

let progress = ProgressHelper.getDownloadProgressBar();
// progress.start(stat.size, 0);

let client: string;
try {
client = await HttpHelper.downloadFile(new URL(`${fileName}.zip`, mirror), null, {
saveToTempFile: true,
onProgress(progress) {
progress;
},
});
} catch (error) {
LogHelper.error(
Expand All @@ -56,7 +62,7 @@ export class MirrorManager extends AbstractDownloadManager {
this.langManager.getTranslate.DownloadManager.MirrorManager.client.unpacking,
);

const progress = ProgressHelper.getLoadingProgressBar();
progress = ProgressHelper.getLoadingProgressBar();
const stat = statSync(client);
progress.start(stat.size, 0);

Expand Down

0 comments on commit 31899e3

Please sign in to comment.