Created
February 25, 2020 17:53
-
-
Save olafurpg/7b220197f82f8275b08d12e94921701d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/metals/src/main/scala/scala/meta/internal/pantsbuild/BloopPants.scala b/metals/src/main/scala/scala/meta/internal/pantsbuild/BloopPants.scala | |
index 688deb9..fa369bd 100644 | |
--- a/metals/src/main/scala/scala/meta/internal/pantsbuild/BloopPants.scala | |
+++ b/metals/src/main/scala/scala/meta/internal/pantsbuild/BloopPants.scala | |
@@ -605,19 +605,18 @@ private class BloopPants( | |
private def cleanStaleBloopFiles( | |
generatedProjects: collection.Set[Path] | |
): Unit = { | |
- val ls = Files.list(bloopDir) | |
- try { | |
- ls.filter { path => | |
- Files.isRegularFile(path) && | |
- path.getFileName().toString().endsWith(".json") && | |
- !generatedProjects(path) | |
- } | |
- .forEach { path => | |
- Files.delete(path) | |
- } | |
- } finally { | |
- ls.close() | |
- } | |
+ val jsonPattern = FileSystems.getDefault().getPathMatcher("glob:*.json") | |
+ AbsolutePath(bloopDir).list | |
+ .filter { path => | |
+ // Re-implementation of https://github.com/scalacenter/bloop/blob/e014760490bf140e2755eb91260bdaf9a75e4476/integrations/sbt-bloop/src/main/scala/bloop/integrations/sbt/SbtBloop.scala#L1064-L1079 | |
+ path.isFile && | |
+ jsonPattern.matches(path.toNIO) && | |
+ !path.filename == "bloop.settings.json" && | |
+ !generatedProjects(path) | |
+ } | |
+ .foreach { path => | |
+ Files.deleteIfExists(path.toNIO) | |
+ } | |
} | |
// See https://github.com/scalatest/scalatest/pull/1739 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment