import { Log } from '@spinajs/log-common'; import { CronJob } from 'cron'; import { fs, IFsTempOptions } from './interfaces.js'; /** * Cleanup policy for temporary filesystems. Implement and register * to customize which files are considered stale and how they are removed, * then select it via `cleanupStrategy` option of fsTemp provider. * * Strategy also owns its schedule - scheduling mechanism ( interval, cron, ... ) * is strategy specific and implemented in `start` / `stop`. * * Strategies hold scheduling state per temp filesystem, so implementations * must be registered with `@NewInstance()` - otherwise a single instance * would be shared between all temp filesystems. */ export declare abstract class TempCleanupStrategy { protected Logger: Log; /** * Performs single cleanup sweep on given filesystem. * * @param fs backend filesystem holding temp files * @param options temp fs configuration ( maxFileAge etc. ) */ abstract cleanup(fs: fs, options: IFsTempOptions): Promise; /** * Starts scheduled cleanup - how sweeps are scheduled is up to the strategy. * * @param fs backend filesystem holding temp files * @param options temp fs configuration */ abstract start(fs: fs, options: IFsTempOptions): void; /** * Stops scheduled cleanup. Safe to call multiple times. */ abstract stop(): void; /** * Single sweep guarded against errors - remote backends can fail * ( network etc. ), scheduler tick must never crash. */ protected safeCleanup(fs: fs, options: IFsTempOptions): Promise; } /** * Default cleanup - deletes first level files older than `maxFileAge` seconds, * checked every `cleanupInterval` milliseconds. * * File age is taken from CreationTime when valid, otherwise from ModifiedTime - * remote backends often lack creation time ( s3 reports epoch, ftp reports none ). * Files with no usable timestamp are skipped. It does not check files recursively * in subdirectories. */ export declare class MaxAgeTempCleanupStrategy extends TempCleanupStrategy { /** * timer instance used by interval-based scheduling */ protected cleanupTimer: NodeJS.Timeout | null; start(fs: fs, options: IFsTempOptions): void; stop(): void; cleanup(fs: fs, options: IFsTempOptions): Promise; } /** * Same sweep as MaxAgeTempCleanupStrategy ( `maxFileAge` still applies ), * but scheduled by cron expression from `cleanupCronExpression` option * instead of fixed interval. Expression is required - creation fails without it. */ export declare class CronTempCleanupStrategy extends MaxAgeTempCleanupStrategy { protected cronJob: CronJob | null; start(fs: fs, options: IFsTempOptions): void; stop(): void; } //# sourceMappingURL=temp-cleanup-strategy.d.ts.map