mirror of
https://github.com/rharkor/caching-for-turbo.git
synced 2025-06-08 01:37:01 +09:00
refactor: add logs for debubg
This commit is contained in:
parent
9f9877153c
commit
bc2c5337c1
2 changed files with 21 additions and 9 deletions
|
@ -159,22 +159,27 @@ export const getS3Provider = (): TProvider => {
|
|||
|
||||
const list = async (): Promise<TListFile[]> => {
|
||||
try {
|
||||
const listCommand = new ListObjectsV2Command({
|
||||
Bucket: s3Bucket,
|
||||
Prefix: s3Prefix
|
||||
})
|
||||
|
||||
const files: TListFile[] = []
|
||||
let continuationToken: string | undefined
|
||||
|
||||
do {
|
||||
if (continuationToken) {
|
||||
listCommand.input.ContinuationToken = continuationToken
|
||||
}
|
||||
// Create a new command for each request with the current continuation token
|
||||
const listCommand = new ListObjectsV2Command({
|
||||
Bucket: s3Bucket,
|
||||
Prefix: s3Prefix,
|
||||
MaxKeys: 1000,
|
||||
ContinuationToken: continuationToken
|
||||
})
|
||||
|
||||
core.debug(
|
||||
`Listing S3 objects with prefix ${s3Prefix}${continuationToken ? ' and continuation token' : ''}`
|
||||
)
|
||||
|
||||
const response = await s3Client.send(listCommand)
|
||||
|
||||
if (response.Contents) {
|
||||
if (response.Contents && response.Contents.length > 0) {
|
||||
core.debug(`Found ${response.Contents.length} objects`)
|
||||
|
||||
const objects = response.Contents.filter(obj => obj.Key).map(
|
||||
(obj): TListFile => {
|
||||
return {
|
||||
|
@ -189,8 +194,12 @@ export const getS3Provider = (): TProvider => {
|
|||
}
|
||||
|
||||
continuationToken = response.NextContinuationToken
|
||||
if (continuationToken) {
|
||||
core.debug(`NextContinuationToken: ${continuationToken}`)
|
||||
}
|
||||
} while (continuationToken)
|
||||
|
||||
core.debug(`Total files listed: ${files.length}`)
|
||||
return files
|
||||
} catch (error) {
|
||||
core.error(`Error listing artifacts from S3: ${error}`)
|
||||
|
|
|
@ -44,6 +44,9 @@ export async function cleanup(ctx: RequestContext) {
|
|||
|
||||
const files = await provider.list()
|
||||
|
||||
ctx.log.info(`Found ${files.length} files in cache`)
|
||||
core.info(JSON.stringify(files, null, 2))
|
||||
|
||||
const fileToDelete: TListFile[] = []
|
||||
if (maxAgeParsed) {
|
||||
const now = new Date()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue