Skip to content

Commit

Permalink
bugfix: Make sure tmp directories are removed
Browse files Browse the repository at this point in the history
Fixes #2415
  • Loading branch information
tgodzik committed Sep 6, 2024
1 parent 20b5e9f commit c8afe70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions backend/src/main/scala/bloop/BloopClassFileManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions backend/src/main/scala/bloop/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -544,6 +544,7 @@ object Compiler {
}

val deleteNewClassesDir = Task(BloopPaths.delete(AbsolutePath(newClassesDir)))
val cleanUpTemporaryFiles = Task(fileManager.deleteTemporaryFiles())
val publishClientAnalysis = Task {
rebaseAnalysisClassFiles(
analysis,
Expand All @@ -555,7 +556,12 @@ object Compiler {
.flatMap(clientClassesObserver.nextAnalysis)
Task
.gatherUnordered(
List(deleteNewClassesDir, updateClientState, writeAnalysisIfMissing)
List(
deleteNewClassesDir,
updateClientState,
writeAnalysisIfMissing,
cleanUpTemporaryFiles
)
)
.flatMap(_ => publishClientAnalysis)
.onErrorHandleWith(err => {
Expand All @@ -565,7 +571,6 @@ object Compiler {
.doOnFinish(_ => Task(clientReporter.reportEndCompilation()))
}
}

Result.Success(
compileInputs.uniqueInputs,
compileInputs.reporter,
Expand Down

0 comments on commit c8afe70

Please sign in to comment.