Update TypedPath apis

I renamed getPath to toPath in io so we need to update sbt to using the
correct api.
This commit is contained in:
Ethan Atkins
2019-01-16 13:22:56 -08:00
parent 48394c81d5
commit 161dfd77f2
4 changed files with 16 additions and 16 deletions
@@ -150,8 +150,8 @@ object Watched {
projectSources: Seq[WatchSource]
): Event[StampedFile] => Watched.Action =
event =>
if (sources.exists(_.accept(event.entry.typedPath.getPath))) Watched.Trigger
else if (projectSources.exists(_.accept(event.entry.typedPath.getPath))) event match {
if (sources.exists(_.accept(event.entry.typedPath.toPath))) Watched.Trigger
else if (projectSources.exists(_.accept(event.entry.typedPath.toPath))) event match {
case Update(prev, cur, _) if prev.value.map(_.stamp) != cur.value.map(_.stamp) => Reload
case _: Creation[_] | _: Deletion[_] => Reload
case _ => Ignore
@@ -365,14 +365,14 @@ object Watched {
if (action == HandleError) "error"
else if (action.isInstanceOf[Custom]) action.toString
else "cancellation"
logger.debug(s"Stopping watch due to $cause from ${event.entry.typedPath.getPath}")
logger.debug(s"Stopping watch due to $cause from ${event.entry.typedPath.toPath}")
action
case (Trigger, Some(event)) =>
logger.debug(s"Triggered by ${event.entry.typedPath.getPath}")
logger.debug(s"Triggered by ${event.entry.typedPath.toPath}")
config.triggeredMessage(event.entry.typedPath, count).foreach(info)
Trigger
case (Reload, Some(event)) =>
logger.info(s"Reload triggered by ${event.entry.typedPath.getPath}")
logger.info(s"Reload triggered by ${event.entry.typedPath.toPath}")
Reload
case _ =>
nextAction()
@@ -580,18 +580,18 @@ object StampedFile {
val binaryConverter: TypedPath => StampedFile =
new StampedFileImpl(_: TypedPath, forceLastModified = true)
val converter: TypedPath => StampedFile = (tp: TypedPath) =>
tp.getPath.toString match {
tp.toPath.toString match {
case s if s.endsWith(".jar") => binaryConverter(tp)
case s if s.endsWith(".class") => binaryConverter(tp)
case _ => sourceConverter(tp)
}
private class StampedFileImpl(typedPath: TypedPath, forceLastModified: Boolean)
extends java.io.File(typedPath.getPath.toString)
extends java.io.File(typedPath.toPath.toString)
with StampedFile {
override val stamp: Stamp =
if (forceLastModified || typedPath.isDirectory)
Stamper.forLastModified(typedPath.getPath.toFile)
else Stamper.forHash(typedPath.getPath.toFile)
Stamper.forLastModified(typedPath.toPath.toFile)
else Stamper.forHash(typedPath.toPath.toFile)
}
}
@@ -78,12 +78,12 @@ class WatchedSpec extends FlatSpec with Matchers {
val config = Defaults.config(
sources = Seq(WatchSource(realDir)),
preWatch = (count, _) => if (count == 2) CancelWatch else Ignore,
onWatchEvent = e => if (e.entry.typedPath.getPath == foo) Trigger else Ignore,
onWatchEvent = e => if (e.entry.typedPath.toPath == foo) Trigger else Ignore,
triggeredMessage = (tp, _) => { queue += tp; None },
watchingMessage = _ => { Files.createFile(bar); Thread.sleep(5); Files.createFile(foo); None }
)
Watched.watch(NullInputStream, () => Right(true), config) shouldBe CancelWatch
queue.toIndexedSeq.map(_.getPath) shouldBe Seq(foo)
queue.toIndexedSeq.map(_.toPath) shouldBe Seq(foo)
}
it should "enforce anti-entropy" in IO.withTemporaryDirectory { dir =>
val realDir = dir.toRealPath
@@ -107,7 +107,7 @@ class WatchedSpec extends FlatSpec with Matchers {
}
)
Watched.watch(NullInputStream, () => Right(true), config) shouldBe CancelWatch
queue.toIndexedSeq.map(_.getPath) shouldBe Seq(bar, foo)
queue.toIndexedSeq.map(_.toPath) shouldBe Seq(bar, foo)
}
it should "halt on error" in IO.withTemporaryDirectory { dir =>
val halted = new AtomicBoolean(false)