Skip to content

Commit c7f788a

Browse files
authored
Merge pull request #7 from Maddimax/releases/v1.1
Fixed downloading snapshots
2 parents 99df971 + bc5b46c commit c7f788a

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

__tests__/main.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('action', () => {
4040
getInputMock.mockImplementation(name => {
4141
switch (name) {
4242
case 'version':
43-
return '14.0.0'
43+
return '15.0.0-beta1'
4444
case 'unzip-to':
4545
return tmpDir
4646
default:

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,31 @@ async function downloadPackage(
2424
): Promise<void> {
2525
const res = await fetch(url)
2626
if (!res.body) throw new Error('Response body is undefined')
27+
if (res.status !== 200) {
28+
throw new Error(`Failed to download ${url}: ${res.statusText}`)
29+
}
2730
const fileStream = fs.createWriteStream(destination, { flags: 'wx' })
2831
return finished(Readable.fromWeb(res.body as ReadableStream).pipe(fileStream))
2932
}
3033

3134
async function downloadQtC(urls: string[]): Promise<string[]> {
35+
const errors: string[] = []
3236
const packages = ['qtcreator.7z', 'qtcreator_dev.7z']
3337
for (const url of urls) {
3438
try {
3539
for (const packageName of packages) {
36-
console.log(`Downloading ${url}/${packageName}`)
37-
await downloadPackage(
38-
`${url}/${packageName}`,
39-
`${tmpDir}/${packageName}`
40-
)
40+
const fullUrl = `${url}/${packageName}`
41+
console.log(`Downloading ${fullUrl}`)
42+
await downloadPackage(fullUrl, `${tmpDir}/${packageName}`)
4143
}
4244
return packages.map(packageName => `${tmpDir}/${packageName}`)
4345
} catch (error) {
44-
console.error(`Failed to download from ${url}:`, error)
46+
errors.push((error as Error).message)
4547
}
4648
}
47-
throw new Error('Failed to download Qt Creator packages')
49+
throw new Error(
50+
`Failed to download Qt Creator packages: ${errors.join('\n')}`
51+
)
4852
}
4953

5054
async function extract(archive: string, destination: string): Promise<void> {

0 commit comments

Comments
 (0)