Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobMGEvans committed Aug 29, 2023
1 parent b744c5b commit 7fe1faa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/autoCacheBust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function r2CacheCollector() {

async function deleteKeys(env: Env, cacheDeletion: ReturnType<typeof r2CacheCollector>) {
if (cacheDeletion.getKeys().length > 0) {
await env.R2_STORE.delete(cacheDeletion.getKeys());
await env.R2_ARTIFACT_ARCHIVE.delete(cacheDeletion.getKeys());
}
}

Expand All @@ -51,7 +51,7 @@ async function processList(list: R2Objects, env: Env) {
}

export async function bustOldCache(env: Env, cursor?: string) {
const list = await env.R2_STORE.list({ limit: RECORDS_BATCH_SIZE, cursor });
const list = await env.R2_ARTIFACT_ARCHIVE.list({ limit: RECORDS_BATCH_SIZE, cursor });
await processList(list, env);

if (list.truncated) {
Expand Down
6 changes: 3 additions & 3 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ router.put('/v8/artifacts/:artifactID', zValidator('param', paramValidator), zVa
}

const artifactTag = c.req.headers.get('x-artifact-tag');
const r2Object = await c.env.R2_STORE.put(`${teamID}/${artifactID}`, c.req.body, {
const r2Object = await c.env.R2_ARTIFACT_ARCHIVE.put(`${teamID}/${artifactID}`, c.req.body, {
customMetadata: artifactTag
? {
artifactTag,
Expand All @@ -69,11 +69,11 @@ router.get('/v8/artifacts/:artifactID', zValidator('param', paramValidator), zVa
}

if (artifactID === 'list') {
const list = await c.env.R2_STORE.list();
const list = await c.env.R2_ARTIFACT_ARCHIVE.list();
return c.json(list.objects.map((object) => object));
}

const r2Object = await c.env.R2_STORE.get(`${teamID}/${artifactID}`);
const r2Object = await c.env.R2_ARTIFACT_ARCHIVE.get(`${teamID}/${artifactID}`);
if (!r2Object) {
return c.notFound();
}
Expand Down
2 changes: 1 addition & 1 deletion worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
type Env = {
ENVIRONMENT: 'production';
EXPIRATION_HOURS: '168' | number;
R2_STORE: R2Bucket;
R2_ARTIFACT_ARCHIVE: R2Bucket;
TURBO_TOKEN: string;
};
2 changes: 1 addition & 1 deletion wrangler.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"r2_buckets": [
{
"binding": "R2_STORE",
"binding": "R2_ARTIFACT_ARCHIVE",
"bucket_name": "turbo-cache",
"preview_bucket_name": "turbo-cache-preview"
}
Expand Down

0 comments on commit 7fe1faa

Please sign in to comment.