Skip to content

Commit

Permalink
Create asset-off-perm bucket for asset manager and pin deployment ver…
Browse files Browse the repository at this point in the history
…sion (#2886)

This PR creates a "asset-off-perm" bucket for the asset manager (see
WATonomous/asset-manager#1) and pins the
deployment version of asset manager to avoid accidental upgrades.
  • Loading branch information
ben-z authored Jun 29, 2024
1 parent 61f24c6 commit 335fb08
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions components/assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const sha256Cache = new Map<string, string>();
const RESOLVER_URL_PREFIXES = [
"https://rgw.watonomous.ca/asset-temp",
"https://rgw.watonomous.ca/asset-perm",
"https://rgw.watonomous.ca/asset-off-perm",
]

const extractSha256FromURI = (uri: string) => {
Expand Down Expand Up @@ -72,7 +73,15 @@ async function resolveURI(uri: string) {
}));

// find the result with the latest expiry date
const result = maxBy(results, res => res?.expiresAt?.getTime() || 0);
const result = maxBy(results, res => {
// No result
if (!res) return 0;

// No expiry date
if (!res.expiresAt) return Infinity;

return res.expiresAt.getTime();
});
if (!result) {
throw new Error('Asset not found.');
}
Expand Down Expand Up @@ -161,12 +170,14 @@ export function AssetInspector() {
</>

)}
{res.result.expiresAt && (
<>
<span className="text-sm text-gray-500 block">Expires</span>
<Pre hasCopyCode className="-mt-5"><Code>{dayjs().to(res.result.expiresAt)} ({res.result.expiresAt.toISOString()})</Code></Pre>
</>
)}
<>
<span className="text-sm text-gray-500 block">Expires</span>
<Pre hasCopyCode className="-mt-5"><Code>{
res.result.expiresAt ?
`${dayjs().to(res.result.expiresAt)} (${res.result.expiresAt.toISOString()})` :
'Never'
}</Code></Pre>
</>
{res.result.headers && (
<>
<span className="text-sm text-gray-500 block">Raw Headers</span>
Expand Down

0 comments on commit 335fb08

Please sign in to comment.