Skip to content

Commit

Permalink
Merge pull request #2423 from tgodzik/remove-tempdirs-always
Browse files Browse the repository at this point in the history
bugfix: Make sure tmp directories are removed
  • Loading branch information
tgodzik authored Sep 9, 2024
2 parents c6630f1 + c8afe70 commit a622b85
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 a622b85

Please sign in to comment.