From c8afe7071eb3eb1dabb80a33ef0edf33d2ecf23a Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Fri, 6 Sep 2024 18:31:00 +0200 Subject: [PATCH] bugfix: Make sure tmp directories are removed Fixes https://github.com/scalacenter/bloop/issues/2415 --- .../src/main/scala/bloop/BloopClassFileManager.scala | 4 ++++ backend/src/main/scala/bloop/Compiler.scala | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/src/main/scala/bloop/BloopClassFileManager.scala b/backend/src/main/scala/bloop/BloopClassFileManager.scala index 3500a0d45..103bbaa37 100644 --- a/backend/src/main/scala/bloop/BloopClassFileManager.scala +++ b/backend/src/main/scala/bloop/BloopClassFileManager.scala @@ -57,6 +57,10 @@ final class BloopClassFileManager( allInvalidatedClassFilesForProject } + def deleteTemporaryFiles(): Unit = { + BloopPaths.delete(AbsolutePath(backupDir)) + } + private[this] val invalidatedClassFilesInDependentProjects: Set[File] = { inputs.invalidatedClassFilesInDependentProjects -- inputs.generatedClassFilePathsInDependentProjects.valuesIterator diff --git a/backend/src/main/scala/bloop/Compiler.scala b/backend/src/main/scala/bloop/Compiler.scala index 677401e76..f4df70685 100644 --- a/backend/src/main/scala/bloop/Compiler.scala +++ b/backend/src/main/scala/bloop/Compiler.scala @@ -275,7 +275,7 @@ object Compiler { val backgroundTasksForFailedCompilation = new mutable.ListBuffer[CompileBackgroundTasks.Sig]() - def newFileManager: ClassFileManager = { + def newFileManager: BloopClassFileManager = { new BloopClassFileManager( Files.createTempDirectory("bloop"), compileInputs, @@ -544,6 +544,7 @@ object Compiler { } val deleteNewClassesDir = Task(BloopPaths.delete(AbsolutePath(newClassesDir))) + val cleanUpTemporaryFiles = Task(fileManager.deleteTemporaryFiles()) val publishClientAnalysis = Task { rebaseAnalysisClassFiles( analysis, @@ -555,7 +556,12 @@ object Compiler { .flatMap(clientClassesObserver.nextAnalysis) Task .gatherUnordered( - List(deleteNewClassesDir, updateClientState, writeAnalysisIfMissing) + List( + deleteNewClassesDir, + updateClientState, + writeAnalysisIfMissing, + cleanUpTemporaryFiles + ) ) .flatMap(_ => publishClientAnalysis) .onErrorHandleWith(err => { @@ -565,7 +571,6 @@ object Compiler { .doOnFinish(_ => Task(clientReporter.reportEndCompilation())) } } - Result.Success( compileInputs.uniqueInputs, compileInputs.reporter,