Skip to content

Commit

Permalink
Merge pull request #7 from Maddimax/releases/v1.1
Browse files Browse the repository at this point in the history
Fixed downloading snapshots
  • Loading branch information
Maddimax authored Aug 1, 2024
2 parents 99df971 + bc5b46c commit c7f788a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('action', () => {
getInputMock.mockImplementation(name => {
switch (name) {
case 'version':
return '14.0.0'
return '15.0.0-beta1'
case 'unzip-to':
return tmpDir
default:
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,31 @@ async function downloadPackage(
): Promise<void> {
const res = await fetch(url)
if (!res.body) throw new Error('Response body is undefined')
if (res.status !== 200) {
throw new Error(`Failed to download ${url}: ${res.statusText}`)
}
const fileStream = fs.createWriteStream(destination, { flags: 'wx' })
return finished(Readable.fromWeb(res.body as ReadableStream).pipe(fileStream))
}

async function downloadQtC(urls: string[]): Promise<string[]> {
const errors: string[] = []
const packages = ['qtcreator.7z', 'qtcreator_dev.7z']
for (const url of urls) {
try {
for (const packageName of packages) {
console.log(`Downloading ${url}/${packageName}`)
await downloadPackage(
`${url}/${packageName}`,
`${tmpDir}/${packageName}`
)
const fullUrl = `${url}/${packageName}`
console.log(`Downloading ${fullUrl}`)
await downloadPackage(fullUrl, `${tmpDir}/${packageName}`)
}
return packages.map(packageName => `${tmpDir}/${packageName}`)
} catch (error) {
console.error(`Failed to download from ${url}:`, error)
errors.push((error as Error).message)
}
}
throw new Error('Failed to download Qt Creator packages')
throw new Error(
`Failed to download Qt Creator packages: ${errors.join('\n')}`
)
}

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

0 comments on commit c7f788a

Please sign in to comment.