Skip to content

Commit

Permalink
Ignore FileSystemException-s when deleting temporary launcher on Wind…
Browse files Browse the repository at this point in the history
…ows (#23)
  • Loading branch information
alexarchambault authored May 20, 2020
1 parent a1e4690 commit 3756726
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/src/main/scala/ammrunner/AmmoniteFetcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ammrunner

import java.io.{File, InputStream, OutputStream}
import java.nio.charset.{Charset, StandardCharsets}
import java.nio.file.{Files, Path}
import java.nio.file.{Files, FileSystemException, Path}

import coursierapi.{Cache, Dependency, Fetch, Logger, ResolutionParams}
import coursier.launcher.{BootstrapGenerator, ClassLoaderContent, ClassPathEntry}
Expand Down Expand Up @@ -127,7 +127,11 @@ import scala.io.{BufferedSource, Codec}
new Thread {
setDaemon(true)
override def run(): Unit =
Files.deleteIfExists(tmpFile)
try Files.deleteIfExists(tmpFile)
catch {
case e: FileSystemException if Command.isWindows =>
System.err.println(s"Error deleting $tmpFile: $e")
}
}
)
BootstrapGenerator.generate(params, tmpFile)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/ammrunner/Command.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import scala.annotation.tailrec

object Command {

private lazy val isWindows: Boolean =
private[ammrunner] lazy val isWindows: Boolean =
Option(System.getProperty("os.name"))
.map(_.toLowerCase(Locale.ROOT))
.exists(_.contains("windows"))
Expand Down

0 comments on commit 3756726

Please sign in to comment.