From e95bead6a0ee006dc71b71cb55f3b4ba33e56353 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Fri, 16 Mar 2012 14:28:15 -0700 Subject: [PATCH] Ignore hidden folders and test the hiding of hidden files --- lib/play/library.rb | 2 +- test/library_test.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/play/library.rb b/lib/play/library.rb index 5fe77e34..55baa075 100644 --- a/lib/play/library.rb +++ b/lib/play/library.rb @@ -17,7 +17,7 @@ def self.monitor # # Returns an Array of String file paths. def self.fs_songs(path) - `find -L "#{path}" -type f ! -name '.*'`.split("\n") + `find -L "#{path}" -type f ! -path '#{path}/.*' ! -name '.*'`.split("\n") end # Imports an array of songs into the database. diff --git a/test/library_test.rb b/test/library_test.rb index 1980e63b..c9f1f041 100644 --- a/test/library_test.rb +++ b/test/library_test.rb @@ -5,7 +5,9 @@ end test "fs_songs" do - FileUtils.mkdir_p '/tmp/play' + FileUtils.mkdir_p '/tmp/play/.hidden' + FileUtils.touch '/tmp/play/.hidden/song_1' + FileUtils.touch '/tmp/play/.song_1' FileUtils.touch '/tmp/play/song_1' FileUtils.touch '/tmp/play/song_2' assert_equal 2, Library.fs_songs('/tmp/play').size