Skip to content

Commit

Permalink
Merge pull request #1500 from olafurpg/1499
Browse files Browse the repository at this point in the history
Fix metacp AccessDeniedException on Windows
  • Loading branch information
olafurpg committed Apr 13, 2018
2 parents 0b41ec6 + 2938a04 commit 3acc732
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ class Main(settings: Settings, reporter: Reporter) {
cacheEntry.toNIO,
StandardCopyOption.REPLACE_EXISTING
)
case _: AccessDeniedException if scala.util.Properties.isWin =>
// AccessDeniedException seems to be thrown on Windows when ATOMIC_MOVE is provided
// and the target file is being used elsewhere, see https://github.com/scalameta/scalameta/issues/1499
Files.move(
tmp,
cacheEntry.toNIO,
StandardCopyOption.REPLACE_EXISTING
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ abstract class BaseMetacpSuite extends BaseCliSuite {
val tmp: AbsolutePath = AbsolutePath(Files.createTempDirectory("metacp"))
tmp.toFile.deleteOnExit()

def runMetacp(classpath: Classpath): Option[Classpath] = {
val settings = Settings().withClasspath(classpath).withCacheDir(tmp).withPar(true)
val reporter = Reporter().withOut(System.out).withErr(System.err)
Metacp.process(settings, reporter)
}

def checkMetacp(name: String, classpath: () => Classpath): Unit = {
test(name) {
val settings = Settings().withClasspath(classpath()).withCacheDir(tmp).withPar(true)
val reporter = Reporter().withOut(System.out).withErr(System.err)
val result = Metacp.process(settings, reporter)
val result = runMetacp(classpath())
assert(result.nonEmpty)
}
}
Expand Down

0 comments on commit 3acc732

Please sign in to comment.