Add request header and debug statements
This commit is contained in:
@ -120,7 +120,8 @@ export async function reserveCache(
|
||||
};
|
||||
const response = await restClient.create<ReserverCacheResponse>(
|
||||
"caches",
|
||||
reserveCacheRequest
|
||||
reserveCacheRequest,
|
||||
getRequestOptions()
|
||||
);
|
||||
|
||||
return response?.result?.cacheId ?? -1;
|
||||
@ -149,6 +150,7 @@ async function uploadChunk(
|
||||
data: Buffer,
|
||||
offset: number
|
||||
): Promise<IRestResponse<void>> {
|
||||
core.debug(`Uploading chunk of size ${data.byteLength} bytes at offset ${offset}`);
|
||||
const requestOptions = getRequestOptions();
|
||||
requestOptions.additionalHeaders = {
|
||||
"Content-Type": "application/octet-stream",
|
||||
@ -179,6 +181,7 @@ export async function saveCache(
|
||||
): Promise<void> {
|
||||
const restClient = createRestClient();
|
||||
|
||||
core.debug("Uploading chunks");
|
||||
// Upload Chunks
|
||||
const stream = fs.createReadStream(archivePath);
|
||||
let streamIsClosed = false;
|
||||
@ -195,6 +198,7 @@ export async function saveCache(
|
||||
offset += MAX_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
core.debug("Awaiting all uplaods");
|
||||
const responses = await Promise.all(uploads);
|
||||
|
||||
const failedResponse = responses.find(
|
||||
@ -206,6 +210,7 @@ export async function saveCache(
|
||||
);
|
||||
}
|
||||
|
||||
core.debug("Commiting cache");
|
||||
// Commit Cache
|
||||
const cacheSize = utils.getArchiveFileSize(archivePath);
|
||||
const commitCacheResponse = await commitCache(
|
||||
|
@ -35,12 +35,13 @@ async function run(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
core.debug("Reserving Cache");
|
||||
const cacheId = await cacheHttpClient.reserveCache(primaryKey);
|
||||
if (cacheId < 0) {
|
||||
core.info(`Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.`);
|
||||
return;
|
||||
}
|
||||
|
||||
core.debug(`Cache ID: ${cacheId}`);
|
||||
const cachePath = utils.resolvePath(
|
||||
core.getInput(Inputs.Path, { required: true })
|
||||
);
|
||||
@ -83,6 +84,7 @@ async function run(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
core.debug("Saving Cache");
|
||||
await cacheHttpClient.saveCache(cacheId, archivePath);
|
||||
} catch (error) {
|
||||
utils.logWarning(error.message);
|
||||
|
Reference in New Issue
Block a user