diff --git a/lib/file_system/backends/fs_inotify.ex b/lib/file_system/backends/fs_inotify.ex index 8232e0d9eb994014b312604144c7db4c41dfa6cd..88b6e562756dd3c3fdddf54bceedf267719fd321 100644 --- a/lib/file_system/backends/fs_inotify.ex +++ b/lib/file_system/backends/fs_inotify.ex @@ -41,7 +41,7 @@ defmodule FileSystem.Backends.FSInotify do end def known_events do - [:created, :deleted, :renamed, :closed, :modified, :isdir, :attribute, :undefined] + [:created, :deleted, :closed, :modified, :isdir, :attribute, :undefined] end defp executable_path do @@ -74,8 +74,8 @@ defmodule FileSystem.Backends.FSInotify do {dirs, rest} -> format = ["%w", "%e", "%f"] |> Enum.join(@sep_char) |> to_charlist args = [ - '-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'create', - '-e', 'delete', '-e', 'attrib', '--format', format, '--quiet', '-m', '-r' + '-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'moved_from', + '-e', 'create', '-e', 'delete', '-e', 'attrib', '--format', format, '--quiet', '-m', '-r' | dirs |> Enum.map(&Path.absname/1) |> Enum.map(&to_charlist/1) ] parse_options(rest, args) @@ -149,12 +149,13 @@ defmodule FileSystem.Backends.FSInotify do end defp convert_flag("CREATE"), do: :created + defp convert_flag("MOVED_TO"), do: :created defp convert_flag("DELETE"), do: :deleted + defp convert_flag("MOVED_FROM"), do: :deleted defp convert_flag("ISDIR"), do: :isdir defp convert_flag("MODIFY"), do: :modified defp convert_flag("CLOSE_WRITE"), do: :modified defp convert_flag("CLOSE"), do: :closed - defp convert_flag("MOVED_TO"), do: :renamed defp convert_flag("ATTRIB"), do: :attribute defp convert_flag(_), do: :undefined end diff --git a/mix.exs b/mix.exs index 1c827e611aa8e31348a1001787a64dcfd382340a..ca2d5c6a57aabc4dcfe0460a0dc38f0d36483aec 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule FileSystem.Mixfile do def project do [ app: :file_system, - version: "0.2.2", + version: "0.2.3", elixir: "~> 1.3", deps: deps(), description: "A file system change watcher wrapper based on [fs](https://github.com/synrc/fs)", diff --git a/test/backends/fs_inotify_test.exs b/test/backends/fs_inotify_test.exs index a687aa4d5d57af95bda1fd572ef48d909689fda2..414ed56ca7cac8c08cdcb04198cdbff27715d9b5 100644 --- a/test/backends/fs_inotify_test.exs +++ b/test/backends/fs_inotify_test.exs @@ -9,20 +9,20 @@ defmodule FileSystem.Backends.FSInotifyTest do end test "supported options" do - assert {:ok, ['-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'create', '-e', - 'delete', '-e', 'attrib', '--format', [37, 119, 1, 37, 101, 1, 37, 102], + assert {:ok, ['-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'moved_from', '-e', 'create', + '-e', 'delete', '-e', 'attrib', '--format', [37, 119, 1, 37, 101, 1, 37, 102], '--quiet', '-m', '-r', '/tmp']} == parse_options(dirs: ["/tmp"], recursive: true) - assert {:ok, ['-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'create', '-e', - 'delete', '-e', 'attrib', '--format', [37, 119, 1, 37, 101, 1, 37, 102], + assert {:ok, ['-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'moved_from', '-e', 'create', + '-e', 'delete', '-e', 'attrib', '--format', [37, 119, 1, 37, 101, 1, 37, 102], '--quiet', '-m', '/tmp']} == parse_options(dirs: ["/tmp"], recursive: false) end test "ignore unsupported options" do - assert {:ok, ['-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'create', '-e', - 'delete', '-e', 'attrib', '--format', [37, 119, 1, 37, 101, 1, 37, 102], + assert {:ok, ['-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'moved_from', '-e', 'create', + '-e', 'delete', '-e', 'attrib', '--format', [37, 119, 1, 37, 101, 1, 37, 102], '--quiet', '-m', '/tmp']} == parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options) end @@ -42,7 +42,7 @@ defmodule FileSystem.Backends.FSInotifyTest do end test "dir moved to" do - assert {"/one/two/file", [:renamed]} == + assert {"/one/two/file", [:created]} == ~w|/one/two/ MOVED_TO file| |> to_port_line |> parse_line end