Fix to use next token

This commit is contained in:
whywaita 2023-04-06 14:58:00 +09:00
parent 548db0e126
commit aa8d90a62f
No known key found for this signature in database
GPG key ID: 410FE9327D2F4F0E
4 changed files with 90 additions and 147 deletions

25
dist/restore/index.js vendored
View file

@ -8147,15 +8147,26 @@ function getCacheEntryS3(s3Options, s3BucketName, keys, paths) {
const s3client = new client_s3_1.S3Client(s3Options);
let contents = new Array();
let s3ContinuationToken = null;
let count = 0;
const param = {
Bucket: s3BucketName
};
for (;;) {
param.ContinuationToken = s3ContinuationToken;
const response = yield s3client.send(new client_s3_1.ListObjectsV2Command(param));
core.debug(`ListObjects Count: ${count}`);
if (s3ContinuationToken != null) {
param.ContinuationToken = s3ContinuationToken;
}
let response;
try {
response = yield s3client.send(new client_s3_1.ListObjectsV2Command(param));
}
catch (e) {
throw new Error(`Error from S3: ${e}`);
}
if (!response.Contents) {
throw new Error(`Cannot found object in bucket ${s3BucketName}`);
}
core.debug(`Found objects ${response.Contents.length}`);
const found = response.Contents.find((content) => content.Key === primaryKey);
if (found && found.LastModified) {
return {
@ -8167,14 +8178,16 @@ function getCacheEntryS3(s3Options, s3BucketName, keys, paths) {
Key: obj.Key,
LastModified: obj.LastModified
}));
core.debug(`Total objects ${contents.length}`);
if (response.IsTruncated) {
s3ContinuationToken = response.ContinuationToken;
s3ContinuationToken = response.NextContinuationToken;
}
else {
break;
}
count++;
}
// not found in primary key, So fallback to next keys
core.debug('Not found in primary key, will fallback to restore keys');
const notPrimaryKey = keys.slice(1);
const found = searchRestoreKeyEntry(notPrimaryKey, contents);
if (found != null && found.LastModified) {
@ -8675,6 +8688,10 @@ const deserializerMiddleware = (options, deserializer) => (next, context) => asy
Object.defineProperty(error, "$response", {
value: response,
});
if (!('$metadata' in error)) {
const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
error.message += "\n " + hint;
}
throw error;
}
};

25
dist/save/index.js vendored
View file

@ -8147,15 +8147,26 @@ function getCacheEntryS3(s3Options, s3BucketName, keys, paths) {
const s3client = new client_s3_1.S3Client(s3Options);
let contents = new Array();
let s3ContinuationToken = null;
let count = 0;
const param = {
Bucket: s3BucketName
};
for (;;) {
param.ContinuationToken = s3ContinuationToken;
const response = yield s3client.send(new client_s3_1.ListObjectsV2Command(param));
core.debug(`ListObjects Count: ${count}`);
if (s3ContinuationToken != null) {
param.ContinuationToken = s3ContinuationToken;
}
let response;
try {
response = yield s3client.send(new client_s3_1.ListObjectsV2Command(param));
}
catch (e) {
throw new Error(`Error from S3: ${e}`);
}
if (!response.Contents) {
throw new Error(`Cannot found object in bucket ${s3BucketName}`);
}
core.debug(`Found objects ${response.Contents.length}`);
const found = response.Contents.find((content) => content.Key === primaryKey);
if (found && found.LastModified) {
return {
@ -8167,14 +8178,16 @@ function getCacheEntryS3(s3Options, s3BucketName, keys, paths) {
Key: obj.Key,
LastModified: obj.LastModified
}));
core.debug(`Total objects ${contents.length}`);
if (response.IsTruncated) {
s3ContinuationToken = response.ContinuationToken;
s3ContinuationToken = response.NextContinuationToken;
}
else {
break;
}
count++;
}
// not found in primary key, So fallback to next keys
core.debug('Not found in primary key, will fallback to restore keys');
const notPrimaryKey = keys.slice(1);
const found = searchRestoreKeyEntry(notPrimaryKey, contents);
if (found != null && found.LastModified) {
@ -8675,6 +8688,10 @@ const deserializerMiddleware = (options, deserializer) => (next, context) => asy
Object.defineProperty(error, "$response", {
value: response,
});
if (!('$metadata' in error)) {
const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
error.message += "\n " + hint;
}
throw error;
}
};