Skip to content

Commit

Permalink
docs: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jaulz authored Jul 26, 2024
1 parent 55058a7 commit a1cee72
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/s3-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ async function s3ListAll(aws: AwsProvider, bucketName: string, pathPrefix?: stri

function findKeysToDelete(existing: { Key: string, Metadata: { 'x-amz-tagging': string | undefined } }[], target: string[]): string[] {
// Returns every key that shouldn't exist anymore
return existing.filter((key) => target.indexOf(key) === -1);
return Object.entries(existing)
.filter(([, object]) => {
const tags = new URLSearchParams(object.Metadata['x-amz-tagging'] ?? '');

Check failure on line 156 in src/utils/s3-sync.ts

View workflow job for this annotation

GitHub Actions / Type

Cannot find name 'URLSearchParams'.

Check failure on line 156 in src/utils/s3-sync.ts

View workflow job for this annotation

GitHub Actions / Lint

Cannot find name 'URLSearchParams'.

Check failure on line 156 in src/utils/s3-sync.ts

View workflow job for this annotation

GitHub Actions / Unit tests (16, 2.36.0)

Cannot find name 'URLSearchParams'.

Check failure on line 156 in src/utils/s3-sync.ts

View workflow job for this annotation

GitHub Actions / Unit tests (16, latest)

Cannot find name 'URLSearchParams'.
Expand All @@ -178,6 +177,7 @@ export async function s3Put(aws: AwsProvider, bucket: string, key: string, fileC
async function s3TagAsObsolete(aws: AwsProvider, bucket: string, keys: string[]): Promise<void> {
for (const key of keys) {
try {
// Add tag that can be read by lifecycle rule
await aws.request<PutObjectTaggingRequest, PutObjectTaggingOutput>("S3", "putObjectTagging", {
Bucket: bucket,
Key: key,
Expand All @@ -203,6 +203,7 @@ async function s3TagAsObsolete(aws: AwsProvider, bucket: string, keys: string[])
contentType = "application/octet-stream";
}

// Copy object to refresh creation time and trigger life cycle rule
await aws.request<CopyObjectRequest, CopyObjectOutput>("S3", "copyObject", {
Bucket: bucket,
Key: key,
Expand Down

0 comments on commit a1cee72

Please sign in to comment.