Class SftpStagingCleanupTask

java.lang.Object
io.leandev.appfuse.file.sftp.SftpStagingCleanupTask
All Implemented Interfaces:
Runnable

public class SftpStagingCleanupTask extends Object implements Runnable

SFTP 暫存區清理任務

定期清理超過保留期限的暫存檔案。此類別是純 Java Runnable, 應用層可透過 Spring @Scheduled 或 Quartz 排程執行。

使用方式

// 建立清理任務
Runnable cleanupTask = SftpStagingCleanupTask.builder()
    .sshClient(sshClient)
    .host("sftp.example.com")
    .port(22)
    .username("user")
    .password("password")
    .basePath("/data/appfuse")
    .retentionPeriod(Duration.ofHours(24))
    .build();

// 應用層排程(Spring 範例)
@Scheduled(fixedRate = 3600000)  // 每小時執行
public void cleanupStagingFiles() {
    cleanupTask.run();
}