Skip to content

Commit

Permalink
bug: 修复ExpiredCacheFileCleanupJob删除目录失败 #1519 (#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixncheng authored Dec 12, 2023
1 parent 94f8821 commit 1267567
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory
import java.io.IOException
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.NoSuchFileException
import java.nio.file.Path
import java.nio.file.attribute.BasicFileAttributes

Expand Down Expand Up @@ -112,6 +113,22 @@ class CleanupFileVisitor(
return expireDuration.seconds > 0
}

override fun visitFileFailed(file: Path, exc: IOException?): FileVisitResult {
if (exc is NoSuchFileException) {
// 目录或者文件已经由其他进程删除。
logger.info("File [$file] already delete.")
} else {
logger.error("Clean up file [$file] error.", exc)
result.errorCount++
if (Files.isRegularFile(file)) {
result.totalFile++
} else {
result.totalFolder++
}
}
return FileVisitResult.CONTINUE
}

/**
* 判断文件是否为临时文件
* @param filePath 文件路径
Expand Down

0 comments on commit 1267567

Please sign in to comment.