Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jackieli-tes committed Jun 8, 2021
1 parent 47d1f9f commit 94927b4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6374,11 +6374,12 @@ function findObject(mc, bucket, keys, compressionMethod) {
core.debug(`Finding object with prefix: ${key}`);
let objects = yield listObjects(mc, bucket, key);
objects = objects.filter((o) => o.name.includes(fn));
core.debug(`Found ${JSON.stringify(objects, null, 2)}`);
if (objects.length < 1) {
continue;
}
const sorted = objects.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime());
core.debug(`Found object ${JSON.stringify(sorted[0])}`);
core.debug(`Using latest ${JSON.stringify(sorted[0])}`);
return sorted[0];
}
throw new Error("Cache item not found");
Expand Down
3 changes: 2 additions & 1 deletion dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6374,11 +6374,12 @@ function findObject(mc, bucket, keys, compressionMethod) {
core.debug(`Finding object with prefix: ${key}`);
let objects = yield listObjects(mc, bucket, key);
objects = objects.filter((o) => o.name.includes(fn));
core.debug(`Found ${JSON.stringify(objects, null, 2)}`);
if (objects.length < 1) {
continue;
}
const sorted = objects.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime());
core.debug(`Found object ${JSON.stringify(sorted[0])}`);
core.debug(`Using latest ${JSON.stringify(sorted[0])}`);
return sorted[0];
}
throw new Error("Cache item not found");
Expand Down
2 changes: 1 addition & 1 deletion src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("utils", () => {
const got = await findObject(
mc,
"actions-cache",
["test-Linux-"],
["foo.bar", "test-Linux-"],
await getCompressionMethod()
);
expect(got).toBeTruthy();
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ export async function findObject(
core.debug(`Finding object with prefix: ${key}`);
let objects = await listObjects(mc, bucket, key);
objects = objects.filter((o) => o.name.includes(fn));
core.debug(`Found ${JSON.stringify(objects, null, 2)}`);
if (objects.length < 1) {
continue;
}
const sorted = objects.sort(
(a, b) => b.lastModified.getTime() - a.lastModified.getTime()
);
core.debug(`Found object ${JSON.stringify(sorted[0])}`);
core.debug(`Using latest ${JSON.stringify(sorted[0])}`);
return sorted[0];
}
throw new Error("Cache item not found");
Expand Down

0 comments on commit 94927b4

Please sign in to comment.