Skip to content

Commit

Permalink
fix: installations being 'broken' if download is interrupted (#201)
Browse files Browse the repository at this point in the history
Fixes #174
  • Loading branch information
connor4312 committed Feb 27, 2023
1 parent ec061f7 commit a08ae56
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@
"when": "$(basename).ts"
}
},
"githubIssues.queries":[
{
"label": "Recent Issues",
"query": "state:open repo:${owner}/${repository} sort:updated-desc"
}
],
"prettier.semi": true
}
}
11 changes: 10 additions & 1 deletion lib/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,17 @@ export async function download(options: Partial<DownloadOptions> = {}): Promise<

for (let i = 0; ; i++) {
try {
// Use a staging directory and rename after unzipping so partially-
// downloaded/unzipped files aren't "stuck" being used.
const downloadStaging = `${downloadedPath}.tmp`;
await fs.promises.rm(downloadStaging, { recursive: true, force: true });

const { stream, format } = await downloadVSCodeArchive({ version, platform, cachePath, reporter, timeout });
await unzipVSCode(reporter, downloadedPath, extractSync, stream, format);
// important! do not put anything async here, since unzipVSCode will need
// to start consuming the stream immediately.
await unzipVSCode(reporter, downloadStaging, extractSync, stream, format);
await fs.promises.rename(downloadStaging, downloadedPath);

reporter.report({ stage: ProgressReportStage.NewInstallComplete, downloadedPath });
break;
} catch (error) {
Expand Down

0 comments on commit a08ae56

Please sign in to comment.