mirror of https://github.com/sbt/sbt.git
Triggered Execution should be aware of rename or move file
This commit is contained in:
parent
47b5790c41
commit
dd628d2441
|
|
@ -10,13 +10,14 @@ object SourceModificationWatch {
|
||||||
{
|
{
|
||||||
import state._
|
import state._
|
||||||
|
|
||||||
def sourceFiles: Iterable[java.io.File] = sourcesFinder.get
|
val sourceFiles: Iterable[java.io.File] = sourcesFinder.get
|
||||||
val (lastModifiedTime, fileCount) =
|
val sourceFilesPath: Set[String] = sourceFiles.map(_.getCanonicalPath)(collection.breakOut)
|
||||||
((0L, 0) /: sourceFiles) { (acc, file) => (math.max(acc._1, file.lastModified), acc._2 + 1) }
|
val lastModifiedTime =
|
||||||
|
(0L /: sourceFiles) { (acc, file) => math.max(acc, file.lastModified) }
|
||||||
|
|
||||||
val sourcesModified =
|
val sourcesModified =
|
||||||
lastModifiedTime > lastCallbackCallTime ||
|
lastModifiedTime > lastCallbackCallTime ||
|
||||||
previousFileCount != fileCount
|
previousFiles != sourceFilesPath
|
||||||
|
|
||||||
val (triggered, newCallbackCallTime) =
|
val (triggered, newCallbackCallTime) =
|
||||||
if (sourcesModified)
|
if (sourcesModified)
|
||||||
|
|
@ -24,7 +25,7 @@ object SourceModificationWatch {
|
||||||
else
|
else
|
||||||
(awaitingQuietPeriod, lastCallbackCallTime)
|
(awaitingQuietPeriod, lastCallbackCallTime)
|
||||||
|
|
||||||
val newState = new WatchState(newCallbackCallTime, fileCount, sourcesModified, if (triggered) count + 1 else count)
|
val newState = new WatchState(newCallbackCallTime, sourceFilesPath, sourcesModified, if (triggered) count + 1 else count)
|
||||||
if (triggered)
|
if (triggered)
|
||||||
(true, newState)
|
(true, newState)
|
||||||
else {
|
else {
|
||||||
|
|
@ -36,7 +37,16 @@ object SourceModificationWatch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final class WatchState(val lastCallbackCallTime: Long, val previousFileCount: Int, val awaitingQuietPeriod: Boolean, val count: Int)
|
final class WatchState(val lastCallbackCallTime: Long, val previousFiles: Set[String], val awaitingQuietPeriod: Boolean, val count: Int) {
|
||||||
|
|
||||||
|
def previousFileCount: Int = previousFiles.size
|
||||||
|
|
||||||
|
@deprecated("Use another constructor", "0.13.6")
|
||||||
|
def this(lastCallbackCallTime: Long, previousFileCount: Int, awaitingQuietPeriod: Boolean, count: Int) {
|
||||||
|
this(lastCallbackCallTime, Set.empty[String], awaitingQuietPeriod, count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object WatchState {
|
object WatchState {
|
||||||
def empty = new WatchState(0L, 0, false, 0)
|
def empty = new WatchState(0L, Set.empty[String], false, 0)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue