Merge pull request #300 from actions/aiyan/listen-on-error

error handling for stream
pull/312/head
Aiqiao Yan 2020-05-11 16:00:51 -04:00 committed by GitHub
commit 916cc60b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 8 deletions

View File

@ -2379,11 +2379,15 @@ function uploadFile(httpClient, cacheId, archivePath) {
const start = offset;
const end = offset + chunkSize - 1;
offset += MAX_CHUNK_SIZE;
yield uploadChunk(httpClient, resourceUrl, () => fs.createReadStream(archivePath, {
yield uploadChunk(httpClient, resourceUrl, () => fs
.createReadStream(archivePath, {
fd,
start,
end,
autoClose: false
})
.on("error", error => {
throw new Error(`Cache upload failed because file read failed with ${error.Message}`);
}), start, end);
}
})));

6
dist/save/index.js vendored
View File

@ -2379,11 +2379,15 @@ function uploadFile(httpClient, cacheId, archivePath) {
const start = offset;
const end = offset + chunkSize - 1;
offset += MAX_CHUNK_SIZE;
yield uploadChunk(httpClient, resourceUrl, () => fs.createReadStream(archivePath, {
yield uploadChunk(httpClient, resourceUrl, () => fs
.createReadStream(archivePath, {
fd,
start,
end,
autoClose: false
})
.on("error", error => {
throw new Error(`Cache upload failed because file read failed with ${error.Message}`);
}), start, end);
}
})));

View File

@ -295,12 +295,18 @@ async function uploadFile(
httpClient,
resourceUrl,
() =>
fs.createReadStream(archivePath, {
fd,
start,
end,
autoClose: false
}),
fs
.createReadStream(archivePath, {
fd,
start,
end,
autoClose: false
})
.on("error", error => {
throw new Error(
`Cache upload failed because file read failed with ${error.Message}`
);
}),
start,
end
);