File tree Expand file tree Collapse file tree 4 files changed +9
-12
lines changed Expand file tree Collapse file tree 4 files changed +9
-12
lines changed Original file line number Diff line number Diff line change 1- import { MongoS3Ttl } from './schema' ;
1+ import { MongoS3TTL } from './schema' ;
22import { S3BucketManager } from '../../s3/buckets/manager' ;
33import { addLog } from '../../system/log' ;
44import { setCron } from '../../system/cron' ;
@@ -9,10 +9,7 @@ export async function clearExpiredMinioFiles() {
99 try {
1010 const now = new Date ( ) ;
1111
12- const expiredFiles = await MongoS3Ttl . find ( {
13- expiredTime : { $exists : true , $ne : null , $lte : now }
14- } ) . lean ( ) ;
15-
12+ const expiredFiles = await MongoS3TTL . find ( { expiredTime : { $lte : now } } ) . lean ( ) ;
1613 if ( expiredFiles . length === 0 ) {
1714 addLog . info ( 'No expired minio files to clean' ) ;
1815 return ;
@@ -37,7 +34,7 @@ export async function clearExpiredMinioFiles() {
3734 } ) ( ) ;
3835
3936 await bucket . delete ( file . minioKey ) ;
40- await MongoS3Ttl . deleteOne ( { _id : file . _id } ) ;
37+ await MongoS3TTL . deleteOne ( { _id : file . _id } ) ;
4138
4239 success ++ ;
4340 addLog . info ( `Deleted expired minio file: ${ file . minioKey } from bucket: ${ file . bucketName } ` ) ;
Original file line number Diff line number Diff line change @@ -21,4 +21,4 @@ const S3TtlSchema = new Schema({
2121S3TtlSchema . index ( { expiredTime : 1 } ) ;
2222S3TtlSchema . index ( { bucketName : 1 , minioKey : 1 } ) ;
2323
24- export const MongoS3Ttl = getMongoModel < S3TtlSchemaType > ( collectionName , S3TtlSchema ) ;
24+ export const MongoS3TTL = getMongoModel < S3TtlSchemaType > ( collectionName , S3TtlSchema ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
1212import type { BucketBasicOperationsType } from '../interface' ;
1313import { createObjectKey , createTempObjectKey } from '../helpers' ;
1414import path from 'node:path' ;
15- import { MongoS3Ttl } from 'common/file/s3Ttl /schema' ;
15+ import { MongoS3TTL } from 'common/file/s3TTL /schema' ;
1616
1717export class S3BaseBucket implements BucketBasicOperationsType {
1818 public client : Client ;
@@ -95,7 +95,7 @@ export class S3BaseBucket implements BucketBasicOperationsType {
9595 const { formData, postURL } = await this . client . presignedPostPolicy ( policy ) ;
9696
9797 if ( temporary ) {
98- await MongoS3Ttl . create ( {
98+ await MongoS3TTL . create ( {
9999 minioKey : key ,
100100 bucketName : this . name ,
101101 expiredTime : new Date ( Date . now ( ) + ttl * 3.6e6 )
Original file line number Diff line number Diff line change 88 type S3Options
99} from '../type' ;
1010import type { S3PublicBucket } from '../buckets/public' ;
11- import { MongoS3Ttl } from '../../file/s3Ttl /schema' ;
11+ import { MongoS3TTL } from '../../file/s3TTL /schema' ;
1212
1313class S3AvatarSource extends S3BaseSource < S3PublicBucket > {
1414 constructor ( options ?: Partial < S3Options > ) {
@@ -42,7 +42,7 @@ class S3AvatarSource extends S3BaseSource<S3PublicBucket> {
4242
4343 async removeAvatar ( avatarWithPrefix : string ) : Promise < void > {
4444 const avatarObjectKey = this . createAvatarObjectKey ( avatarWithPrefix ) ;
45- await MongoS3Ttl . deleteOne ( { minioKey : avatarObjectKey , bucketName : this . bucketName } ) ;
45+ await MongoS3TTL . deleteOne ( { minioKey : avatarObjectKey , bucketName : this . bucketName } ) ;
4646 await this . bucket . delete ( avatarObjectKey ) ;
4747 }
4848
@@ -51,7 +51,7 @@ class S3AvatarSource extends S3BaseSource<S3PublicBucket> {
5151 const avatarObjectKey = tempAvatarObjectKey . replace ( `${ S3Sources . temp } /` , '' ) ;
5252
5353 try {
54- const file = await MongoS3Ttl . findOne ( {
54+ const file = await MongoS3TTL . findOne ( {
5555 bucketName : this . bucketName ,
5656 minioKey : tempAvatarObjectKey
5757 } ) ;
You can’t perform that action at this time.
0 commit comments