Skip to content

Commit f1c8bc5

Browse files
committed
Try to detect failed artifact downloads better
In one instance, the `git-sdk-64-minimal` artifact was downloaded incompletely, but the Action thought it had worked and cached the incomplete set of files. Let's try harder to detect that situation and indicate a failed download. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 83f3990 commit f1c8bc5

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

src/downloader.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,33 @@ async function unzip(
6969
}
7070

7171
return new Promise<void>((resolve, reject) => {
72-
https.get(url, (res: Readable): void => {
73-
res
74-
.pipe(unzipper.Parse())
75-
.on('entry', entry => {
76-
if (!entry.path.startsWith(stripPrefix)) {
77-
process.stderr.write(
78-
`warning: skipping ${entry.path} because it does not start with ${stripPrefix}\n`
79-
)
80-
}
81-
const entryPath = `${outputDirectory}/${entry.path.substring(
82-
stripPrefix.length
83-
)}`
84-
progress(entryPath)
85-
if (entryPath.endsWith('/')) {
86-
mkdirp(entryPath.replace(/\/$/, ''))
87-
entry.autodrain()
88-
} else {
89-
entry.pipe(fs.createWriteStream(`${entryPath}`))
90-
}
91-
})
92-
.on('error', reject)
93-
.on('finish', progress)
94-
.on('finish', resolve)
95-
})
72+
https
73+
.get(url, (res: Readable): void => {
74+
res
75+
.on('error', reject)
76+
.pipe(unzipper.Parse())
77+
.on('entry', entry => {
78+
if (!entry.path.startsWith(stripPrefix)) {
79+
process.stderr.write(
80+
`warning: skipping ${entry.path} because it does not start with ${stripPrefix}\n`
81+
)
82+
}
83+
const entryPath = `${outputDirectory}/${entry.path.substring(
84+
stripPrefix.length
85+
)}`
86+
progress(entryPath)
87+
if (entryPath.endsWith('/')) {
88+
mkdirp(entryPath.replace(/\/$/, ''))
89+
entry.autodrain()
90+
} else {
91+
entry.pipe(fs.createWriteStream(`${entryPath}`))
92+
}
93+
})
94+
.on('error', reject)
95+
.on('finish', progress)
96+
.on('finish', resolve)
97+
})
98+
.on('error', reject)
9699
})
97100
}
98101

0 commit comments

Comments
 (0)