mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-06 03:15:46 -05:00
error handling for stream
This commit is contained in:
parent
5ddc028cc8
commit
4967c8e6c5
3 changed files with 22 additions and 8 deletions
6
dist/restore/index.js
vendored
6
dist/restore/index.js
vendored
|
@ -2379,11 +2379,15 @@ function uploadFile(httpClient, cacheId, archivePath) {
|
||||||
const start = offset;
|
const start = offset;
|
||||||
const end = offset + chunkSize - 1;
|
const end = offset + chunkSize - 1;
|
||||||
offset += MAX_CHUNK_SIZE;
|
offset += MAX_CHUNK_SIZE;
|
||||||
yield uploadChunk(httpClient, resourceUrl, () => fs.createReadStream(archivePath, {
|
yield uploadChunk(httpClient, resourceUrl, () => fs
|
||||||
|
.createReadStream(archivePath, {
|
||||||
fd,
|
fd,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
autoClose: false
|
autoClose: false
|
||||||
|
})
|
||||||
|
.on("error", error => {
|
||||||
|
throw new Error(`Cache upload failed because file read failed with ${error.Message}`);
|
||||||
}), start, end);
|
}), start, end);
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
6
dist/save/index.js
vendored
6
dist/save/index.js
vendored
|
@ -2379,11 +2379,15 @@ function uploadFile(httpClient, cacheId, archivePath) {
|
||||||
const start = offset;
|
const start = offset;
|
||||||
const end = offset + chunkSize - 1;
|
const end = offset + chunkSize - 1;
|
||||||
offset += MAX_CHUNK_SIZE;
|
offset += MAX_CHUNK_SIZE;
|
||||||
yield uploadChunk(httpClient, resourceUrl, () => fs.createReadStream(archivePath, {
|
yield uploadChunk(httpClient, resourceUrl, () => fs
|
||||||
|
.createReadStream(archivePath, {
|
||||||
fd,
|
fd,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
autoClose: false
|
autoClose: false
|
||||||
|
})
|
||||||
|
.on("error", error => {
|
||||||
|
throw new Error(`Cache upload failed because file read failed with ${error.Message}`);
|
||||||
}), start, end);
|
}), start, end);
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
|
@ -295,12 +295,18 @@ async function uploadFile(
|
||||||
httpClient,
|
httpClient,
|
||||||
resourceUrl,
|
resourceUrl,
|
||||||
() =>
|
() =>
|
||||||
fs.createReadStream(archivePath, {
|
fs
|
||||||
fd,
|
.createReadStream(archivePath, {
|
||||||
start,
|
fd,
|
||||||
end,
|
start,
|
||||||
autoClose: false
|
end,
|
||||||
}),
|
autoClose: false
|
||||||
|
})
|
||||||
|
.on("error", error => {
|
||||||
|
throw new Error(
|
||||||
|
`Cache upload failed because file read failed with ${error.Message}`
|
||||||
|
);
|
||||||
|
}),
|
||||||
start,
|
start,
|
||||||
end
|
end
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue