Skip to content

Fix #4929: allow reusing TastyFileManager #4930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions sbt-dotty/src/dotty/tools/sbtplugin/TastyFileManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ import scala.collection.mutable
* temporary directory as class files.
*/
final class TastyFileManager extends ClassFileManager {
private[this] val tempDir = Files.createTempDirectory("backup").toFile
private[this] var _tempDir: File = null
private[this] def tempDir = {
if (_tempDir == null) {
_tempDir = Files.createTempDirectory("backup").toFile
}
_tempDir
}

private[this] val generatedTastyFiles = new mutable.HashSet[File]
private[this] val movedTastyFiles = new mutable.HashMap[File, File]
Expand All @@ -42,7 +48,10 @@ final class TastyFileManager extends ClassFileManager {
IO.deleteFilesEmptyDirs(generatedTastyFiles)
for ((orig, tmp) <- movedTastyFiles) IO.move(tmp, orig)
}
IO.delete(tempDir)
if (_tempDir != null) {
IO.delete(tempDir)
_tempDir = null
}
}

private def tastyFiles(classes: Array[File]): Array[File] = {
Expand Down