Only use a file repository for interactive sessions

I realized that using the cache has the potential to cause issues for
batch processing in CI if some tasks assume that a file created by one
task will immediately be visible in the other. With the cache, there is
typically on O(10ms) latency between a file being created and appearing
in the cache (at least on OSX). When manually running commands, that
latency doesn't matter.
This commit is contained in:
Ethan Atkins 2018-10-06 11:39:05 -07:00
parent b155ffb77b
commit 1f996185e1
2 changed files with 10 additions and 6 deletions

View File

@ -272,8 +272,7 @@ object Defaults extends BuildCommon {
None
},
watchStartMessage := Watched.defaultStartWatch,
fileTreeViewConfig := FileTreeViewConfig
.default(watchAntiEntropy.value, pollInterval.value, pollingDirectories.value),
fileTreeViewConfig := FileManagement.defaultFileTreeView.value,
fileTreeView := state.value
.get(BasicKeys.globalFileTreeView)
.getOrElse(FileTreeView.DEFAULT.asDataView(StampedFile.converter)),
@ -657,8 +656,7 @@ object Defaults extends BuildCommon {
},
watchStartMessage := Watched.projectOnWatchMessage(thisProjectRef.value.project),
watch := watchSetting.value,
fileTreeViewConfig := FileTreeViewConfig
.default(watchAntiEntropy.value, pollInterval.value, pollingDirectories.value)
fileTreeViewConfig := FileManagement.defaultFileTreeView.value
)
def generate(generators: SettingKey[Seq[Task[Seq[File]]]]): Initialize[Task[Seq[File]]] =

View File

@ -13,10 +13,16 @@ import java.nio.file.Path
import sbt.Keys._
import sbt.io.FileTreeDataView.Entry
import sbt.io.syntax.File
import sbt.io.{ FileFilter, FileTreeRepository, FileTreeDataView }
import sbt.{ Def, ScopedTaskable, StampedFile, Task }
import sbt.io.{ FileFilter, FileTreeDataView, FileTreeRepository }
import sbt._
private[sbt] object FileManagement {
private[sbt] def defaultFileTreeView: Def.Initialize[Task[FileTreeViewConfig]] = Def.task {
if (state.value.remainingCommands.exists(_.commandLine == "shell")) {
FileTreeViewConfig
.default(watchAntiEntropy.value, pollInterval.value, pollingDirectories.value)
} else FileTreeViewConfig.sbt1_2_compat(pollInterval.value, watchAntiEntropy.value)
}
private[sbt] implicit class FileTreeDataViewOps[+T](val fileTreeDataView: FileTreeDataView[T]) {
def register(path: Path, maxDepth: Int): Either[IOException, Boolean] = {
fileTreeDataView match {