Skip to content

Commit a6dcf0c

Browse files
committed
fix:修复 notNeed 目录自己的文件没有自动清理问题
1 parent 68eddde commit a6dcf0c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib_bcu_plugin/src/main/java/com/ysj/lib/bytecodeutil/plugin/TransformTask.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,19 @@ abstract class TransformTask : DefaultTask() {
147147

148148
private fun cleanNotNeedOutput(executor: Executor, allNotNeedFileSet: Set<File>): Worker? {
149149
val notNeedOutputDir = notNeedOutput.get().asFile
150-
val list = notNeedOutputDir
151-
.list()
152-
?.mapNotNull {
153-
val dir = File(notNeedOutputDir, it)
154-
if (dir.isDirectory) dir else null
150+
val list = notNeedOutputDir.listFiles() ?: return null
151+
val workCounter: (File) -> Int = { if (it.isDirectory) 1 else 0 }
152+
val worker = Worker(list.sumOf(workCounter), executor)
153+
list.forEach { file ->
154+
if (file.isFile) {
155+
if (file !in allNotNeedFileSet) {
156+
file.delete()
157+
logger.lifecycle(">>> incremental removed: ${file.name}")
158+
}
159+
return@forEach
155160
}
156-
?: return null
157-
val worker = Worker(list.size, executor)
158-
list.forEach { dir ->
159161
worker.submit {
160-
dir.walkBottomUp().forEach {
162+
file.walkBottomUp().forEach {
161163
if (it.isDirectory) {
162164
if (it.list().isNullOrEmpty()) {
163165
it.delete()

0 commit comments

Comments
 (0)