Question

Friends,

I am trying to processing a huge amount of audio files using a Ruby (1.9.3) script by scanning their ID3-Tags using the pretty fast taglib-ruby (0.2.1 via Gem-Server) library.

Here is a part of my code, while audio contains the full file path in a Ruby-String:

begin 
  file_ref = TagLib::FileRef.new(audio) 
  unless file_ref.tag.nil? 
     unless file_ref.tag.artist.nil? or file_ref.tag.title.nil?
       …
     end
  end
ensure
 file_ref = nil
end

Then I get into trouble nearly at the end of the processing. TagLib is complaining about missing read permissions and FileUtils.mv is not longer able to move file afterwards. This is probably the case, because my script does not free file handles TagLib is eating while processing.

Unfortunalty I don not found a certain Ruby method in taglib-ruby API, which eventually call one or better both of TagLibs C-functions:

taglib_tag_free_strings();
taglib_file_free(file);

libmagic Ruby bindings for instance provide a close-Method within its Magic class, so that freeing whithin ensure blocks will work.

Am I just missing the correct Ruby method for taglib-ruby or is it missing at the moment? Is there another way of freeing file handles acquired via Ruby?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top