Skip to content

More than one events generated for a file modification #313

Description

@shivamka1

Hi,

I am trying to watch a config file for modifications with the following piece of code:

object WatchTest extends App {
  implicit val system: ActorSystem = ActorSystem("mySystem")
  val watcher: ActorRef = File(conf_dir + "/application.conf").newWatcher(recursive = false)

  watcher ! on(EventType.ENTRY_MODIFY) { file =>
    println(s"$file got modified")
  }
}

I could watch a single file instead of a directory, right?

This seems to work but the problem is that everytime I am modififying the file, more than one events are getting generated. This is problematic since the sideeffects in the callback can't be called more than once.

Please suggest how can I achieve this or if I am doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions