Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/wavesync/path_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def find_files_to_cleanup(target_path, audio)

pattern = target_path.dirname.join("#{basename}{, * bpm}#{ext}")
Dir.glob(pattern.to_s).map { |f| Pathname(f) }
.reject { |path| path == target_path }
.reject { |path| File.identical?(path.to_s, target_path.to_s) }
end

private
Expand Down
16 changes: 16 additions & 0 deletions test/wavesync/path_resolver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,22 @@ def setup
FileUtils.rm_rf('/tmp/test_cleanup_self')
end

test 'find_files_to_cleanup excludes target file when target path uses different unicode normalization than disk' do
nfc_dir = "/tmp/test_cleanup_nfc/Bj\u00F6rk"
FileUtils.mkdir_p(nfc_dir)
FileUtils.touch("#{nfc_dir}/song 140 bpm.wav")

device = Device.find_by(name: 'Octatrack')
resolver = PathResolver.new(@source_library, '/tmp/test_cleanup_nfc', device)
nfd_target_path = Pathname.new("/tmp/test_cleanup_nfc/Bjo\u0308rk/song 140 bpm.wav")
audio = stub(bpm: 140)
files = resolver.find_files_to_cleanup(nfd_target_path, audio)

assert_equal [], files

FileUtils.rm_rf('/tmp/test_cleanup_nfc')
end

private

def resolver_for(device_name)
Expand Down
Loading