diff --git a/setup.ts b/setup.ts index 14982c7..f4aadcc 100644 --- a/setup.ts +++ b/setup.ts @@ -39,7 +39,7 @@ for(const arch in CC){ run(`cp -r ~/alist/.git .`); // 开始编译 - const addition = `X 'github.com/alist-org/alist/v3/internal/conf.BuiltAt=${new Date().toISOString()}' + const addition = `-X 'github.com/alist-org/alist/v3/internal/conf.BuiltAt=${new Date().toISOString()}' -X 'github.com/alist-org/alist/v3/internal/conf.GoVersion=${ parseFloat(runWithOutput('go version').split('go version ')[1] || '0.1') }' diff --git a/utils.ts b/utils.ts index bb8b392..6b049b4 100644 --- a/utils.ts +++ b/utils.ts @@ -41,8 +41,14 @@ export function cd(dir: string){ } export async function wget(url: string, saveAs: string){ - const fe = await fetch(url), - file = await Deno.open(saveAs, {createNew: true, read: false, write: true}); - if(!fe.ok) throw new Error(`Failed to fetch ${url}`); - await fe.body!.pipeTo(file.writable); + for(let i = 0; i < 3; i++) try{ + const fe = await fetch(url), + file = await Deno.open(saveAs, {createNew: true, read: false, write: true}); + if(!fe.ok) throw new Error(`Failed to fetch ${url}`); + await fe.body!.pipeTo(file.writable); + }catch(e){ + if(i === 2) throw new Error(`Failed to download ${url} after 3 retries: ${e.message}`); + console.warn(`Failed to download ${url}(retry ${i+1}/3): ${e.message}`); + await new Promise(resolve => setTimeout(resolve, 5000)); + } } \ No newline at end of file