Skip to content

Commit

Permalink
apply learnings from wsl download fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Oct 30, 2024
1 parent 2c12f1c commit bd808cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/server/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ async function getLatestBuild(quality: 'stable' | 'insider'): Promise<DownloadIn
export async function getDownloadURL(quality: 'stable' | 'insider', commit: string): Promise<string | undefined> {
return new Promise((resolve, reject) => {
const url = `https://update.code.visualstudio.com/commit:${commit}/web-standalone/${quality}`;
const httpLibrary = url.startsWith('https') ? https : http;
httpLibrary.get(url, { method: 'HEAD', ...getAgent(url) }, res => {
console.log(res.statusCode, res.headers.location);
https.get(url, { method: 'HEAD', ...getAgent(url) }, res => {
if ((res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) && res.headers.location) {
resolve(res.headers.location);
} else {
resolve(undefined);
}
res.resume(); // Discard response body
});
});
}
Expand Down Expand Up @@ -68,6 +67,7 @@ async function downloadAndUntar(downloadUrl: string, destination: string, messag

received += chunk.length;
});
res.on('error', reject);
res.on('end', () => {
if (timeout) {
clearTimeout(timeout);
Expand Down

0 comments on commit bd808cd

Please sign in to comment.