Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Reformat
  • Loading branch information
sake92 committed Nov 17, 2023
commit 0ef0e9b3d6d3f9a331cb57c92e5545b23c4ab8d9
5 changes: 3 additions & 2 deletions os/watch/src/WatchServiceWatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class WatchServiceWatcher(
if (isDir) {
// https://stackoverflow.com/a/6265860/4496364
// on Windows we watch only the root directory
val modifiers: Array[WatchEvent.Modifier] = if (isWin) Array(SensitivityWatchEventModifier.HIGH, ExtendedWatchEventModifier.FILE_TREE)
else Array(SensitivityWatchEventModifier.HIGH)
val modifiers: Array[WatchEvent.Modifier] = if (isWin)
Array(SensitivityWatchEventModifier.HIGH, ExtendedWatchEventModifier.FILE_TREE)
else Array(SensitivityWatchEventModifier.HIGH)
currentlyWatchedPaths.put(
p,
p.toNIO.register(
Expand Down
1 change: 0 additions & 1 deletion os/watch/src/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package object watch {
* changes happening within the watched roots folder, apart from the path
* at which the change happened. It is up to the `onEvent` handler to query
* the filesystem and figure out what happened, and what it wants to do.
*
*/
def watch(
roots: Seq[os.Path],
Expand Down
56 changes: 28 additions & 28 deletions os/watch/test/src/WatchTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ object WatchTests extends TestSuite with TestSuite.Retries {

val tests = Tests {
test("singleFolder") - _root_.test.os.TestUtil.prep { wd =>

val changedPaths = collection.mutable.Set.empty[os.Path]
_root_.os.watch.watch(
Seq(wd),
Expand Down Expand Up @@ -77,12 +76,13 @@ object WatchTests extends TestSuite with TestSuite.Retries {
)

checkFileManglingChanges(wd / "my-new-folder" / "test")

locally {
val expectedChanges = if (isWin) Set(
os.sub / "folder2",
os.sub / "folder3"
) else Set(
)
else Set(
os.sub / "folder2",
os.sub / "folder3",
os.sub / "folder3" / "nestedA",
Expand Down Expand Up @@ -118,31 +118,31 @@ object WatchTests extends TestSuite with TestSuite.Retries {
)
)

checkFileManglingChanges(wd / "folder3" / "nestedA" / "double-nested-file")
checkFileManglingChanges(wd / "folder3" / "nestedB" / "double-nested-file")
checkChanges(
os.symlink(wd / "newlink", wd / "doesntexist"),
Set(os.sub / "newlink")
)

checkChanges(
os.symlink(wd / "newlink2", wd / "folder3"),
Set(os.sub / "newlink2")
)
checkChanges(
os.hardlink(wd / "newlink3", wd / "folder3" / "nestedA" / "a.txt"),
System.getProperty("os.name") match {
case "Mac OS X" =>
Set(
os.sub / "newlink3",
os.sub / "folder3" / "nestedA",
os.sub / "folder3" / "nestedA" / "a.txt"
)
case _ => Set(os.sub / "newlink3")
}
)
checkFileManglingChanges(wd / "folder3" / "nestedA" / "double-nested-file")
checkFileManglingChanges(wd / "folder3" / "nestedB" / "double-nested-file")

checkChanges(
os.symlink(wd / "newlink", wd / "doesntexist"),
Set(os.sub / "newlink")
)

checkChanges(
os.symlink(wd / "newlink2", wd / "folder3"),
Set(os.sub / "newlink2")
)

checkChanges(
os.hardlink(wd / "newlink3", wd / "folder3" / "nestedA" / "a.txt"),
System.getProperty("os.name") match {
case "Mac OS X" =>
Set(
os.sub / "newlink3",
os.sub / "folder3" / "nestedA",
os.sub / "folder3" / "nestedA" / "a.txt"
)
case _ => Set(os.sub / "newlink3")
}
)

}
}
Expand Down