Skip to content

Commit

Permalink
ci: 修复测试问题
Browse files Browse the repository at this point in the history
  • Loading branch information
share121 committed Feb 6, 2025
1 parent 05ee231 commit e497de5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 4 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export async function download(
const mutex = new Mutex();
const { contentLength, filename } = await getURLInfo();
await Deno.mkdir(dirpath, { recursive: true });
const file = await Deno.open(join(dirpath, filename), {
const filePath = join(dirpath, filename);
const file = await Deno.open(filePath, {
write: true,
create: true,
});
Expand Down Expand Up @@ -65,6 +66,8 @@ export async function download(
} finally {
file.close();
}

return filePath;
}

export interface Chunk {
Expand Down
4 changes: 1 addition & 3 deletions main_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { crypto } from "jsr:@std/crypto";
import { join, basename } from "jsr:@std/path";
import { encodeHex } from "jsr:@std/encoding/hex";
import { assertEquals } from "jsr:@std/assert";
import { download } from "./main.ts";
Expand All @@ -9,10 +8,9 @@ Deno.test("Download ISO file test", async () => {
"https://mirrors.tuna.tsinghua.edu.cn/debian-cd/12.9.0-live/amd64/iso-hybrid/debian-live-12.9.0-amd64-kde.iso";
const dirpath = ".";
const threads = 32;
const outputPath = join(dirpath, basename(url));

console.time("Download ISO file test");
await download(url, outputPath, threads);
const outputPath = await download(url, dirpath, threads);
console.timeEnd("Download ISO file test");

console.time("Calculate file hash test");
Expand Down

0 comments on commit e497de5

Please sign in to comment.