diff --git a/dist/restore/index.js b/dist/restore/index.js index 31227c9..c0b3b74 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -109850,21 +109850,25 @@ function findObject(mc, bucket, key, restoreKeys, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { core.debug("Key: " + JSON.stringify(key)); core.debug("Restore keys: " + JSON.stringify(restoreKeys)); - core.debug(`Finding exact macth for: ${key}`); - const exactMatch = yield listObjects(mc, bucket, key); - core.debug(`Found ${JSON.stringify(exactMatch, null, 2)}`); - if (exactMatch.length) { - const result = { item: exactMatch[0], matchingKey: key }; - core.debug(`Using ${JSON.stringify(result)}`); - return result; + core.debug(`Finding exact match for: ${key}`); + const keyMatches = yield listObjects(mc, bucket, key); + core.debug(`Found ${JSON.stringify(keyMatches, null, 2)}`); + if (keyMatches.length > 0) { + const exactMatch = keyMatches.find((obj) => obj.name.startsWith(key)); + if (exactMatch) { + const result = { item: exactMatch, matchingKey: key }; + core.debug(`Found an exact match; using ${JSON.stringify(result)}`); + return result; + } } + core.debug(`Didn't find an exact match`); for (const restoreKey of restoreKeys) { const fn = utils.getCacheFileName(compressionMethod); core.debug(`Finding object with prefix: ${restoreKey}`); let objects = yield listObjects(mc, bucket, restoreKey); objects = objects.filter((o) => o.name.includes(fn)); core.debug(`Found ${JSON.stringify(objects, null, 2)}`); - if (objects.length < 1) { + if (objects.length == 0) { continue; } const sorted = objects.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime()); diff --git a/dist/save/index.js b/dist/save/index.js index d3c8df2..7388d9c 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -109765,21 +109765,25 @@ function findObject(mc, bucket, key, restoreKeys, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { core.debug("Key: " + JSON.stringify(key)); core.debug("Restore keys: " + JSON.stringify(restoreKeys)); - core.debug(`Finding exact macth for: ${key}`); - const exactMatch = yield listObjects(mc, bucket, key); - core.debug(`Found ${JSON.stringify(exactMatch, null, 2)}`); - if (exactMatch.length) { - const result = { item: exactMatch[0], matchingKey: key }; - core.debug(`Using ${JSON.stringify(result)}`); - return result; + core.debug(`Finding exact match for: ${key}`); + const keyMatches = yield listObjects(mc, bucket, key); + core.debug(`Found ${JSON.stringify(keyMatches, null, 2)}`); + if (keyMatches.length > 0) { + const exactMatch = keyMatches.find((obj) => obj.name.startsWith(key)); + if (exactMatch) { + const result = { item: exactMatch, matchingKey: key }; + core.debug(`Found an exact match; using ${JSON.stringify(result)}`); + return result; + } } + core.debug(`Didn't find an exact match`); for (const restoreKey of restoreKeys) { const fn = utils.getCacheFileName(compressionMethod); core.debug(`Finding object with prefix: ${restoreKey}`); let objects = yield listObjects(mc, bucket, restoreKey); objects = objects.filter((o) => o.name.includes(fn)); core.debug(`Found ${JSON.stringify(objects, null, 2)}`); - if (objects.length < 1) { + if (objects.length == 0) { continue; } const sorted = objects.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime()); diff --git a/dist/saveOnly/index.js b/dist/saveOnly/index.js index d8774ba..b94cd03 100644 --- a/dist/saveOnly/index.js +++ b/dist/saveOnly/index.js @@ -109765,21 +109765,25 @@ function findObject(mc, bucket, key, restoreKeys, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { core.debug("Key: " + JSON.stringify(key)); core.debug("Restore keys: " + JSON.stringify(restoreKeys)); - core.debug(`Finding exact macth for: ${key}`); - const exactMatch = yield listObjects(mc, bucket, key); - core.debug(`Found ${JSON.stringify(exactMatch, null, 2)}`); - if (exactMatch.length) { - const result = { item: exactMatch[0], matchingKey: key }; - core.debug(`Using ${JSON.stringify(result)}`); - return result; + core.debug(`Finding exact match for: ${key}`); + const keyMatches = yield listObjects(mc, bucket, key); + core.debug(`Found ${JSON.stringify(keyMatches, null, 2)}`); + if (keyMatches.length > 0) { + const exactMatch = keyMatches.find((obj) => obj.name.startsWith(key)); + if (exactMatch) { + const result = { item: exactMatch, matchingKey: key }; + core.debug(`Found an exact match; using ${JSON.stringify(result)}`); + return result; + } } + core.debug(`Didn't find an exact match`); for (const restoreKey of restoreKeys) { const fn = utils.getCacheFileName(compressionMethod); core.debug(`Finding object with prefix: ${restoreKey}`); let objects = yield listObjects(mc, bucket, restoreKey); objects = objects.filter((o) => o.name.includes(fn)); core.debug(`Found ${JSON.stringify(objects, null, 2)}`); - if (objects.length < 1) { + if (objects.length == 0) { continue; } const sorted = objects.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime()); diff --git a/src/utils.ts b/src/utils.ts index c7e8cd7..1d398ef 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -112,14 +112,18 @@ export async function findObject( core.debug("Key: " + JSON.stringify(key)); core.debug("Restore keys: " + JSON.stringify(restoreKeys)); - core.debug(`Finding exact macth for: ${key}`); - const exactMatch = await listObjects(mc, bucket, key); - core.debug(`Found ${JSON.stringify(exactMatch, null, 2)}`); - if (exactMatch.length) { - const result = { item: exactMatch[0], matchingKey: key }; - core.debug(`Using ${JSON.stringify(result)}`); - return result; + core.debug(`Finding exact match for: ${key}`); + const keyMatches = await listObjects(mc, bucket, key); + core.debug(`Found ${JSON.stringify(keyMatches, null, 2)}`); + if (keyMatches.length > 0) { + const exactMatch = keyMatches.find((obj) => obj.name.startsWith(key)); + if (exactMatch) { + const result = { item: exactMatch, matchingKey: key }; + core.debug(`Found an exact match; using ${JSON.stringify(result)}`); + return result; + } } + core.debug(`Didn't find an exact match`); for (const restoreKey of restoreKeys) { const fn = utils.getCacheFileName(compressionMethod); @@ -127,7 +131,7 @@ export async function findObject( let objects = await listObjects(mc, bucket, restoreKey); objects = objects.filter((o) => o.name.includes(fn)); core.debug(`Found ${JSON.stringify(objects, null, 2)}`); - if (objects.length < 1) { + if (objects.length == 0) { continue; } const sorted = objects.sort(