moumar / ruby-mp3info

ruby-mp3info read low-level informations and manipulate tags on mp3 files.
http://rdoc.info/github/moumar/ruby-mp3info/master/frames
223 stars 57 forks source link

Permission denied error when closing #41

Closed jrq closed 9 years ago

jrq commented 10 years ago

I've upgraded to the new mp3info GEM and now there seems to be a problem when it comes to writing the changes to the MP3 tags. Ruby version 1.9.3, mp3info version 0.8.4, Windows 7 - 64 bit.

Simple program:

require 'mp3info'
mp3 = Mp3Info.open('a.mp3')
mp3.title = 'bogo'
mp3.close

Results in:

Errno::EACCES: Permission denied - (./.a.mp3.tmp, a.mp3)
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-mp3info-0.8.4/lib/mp3info.rb:453:in `rename'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-mp3info-0.8.4/lib/mp3info.rb:453:in `close'
from (irb):6
from D:/Ruby193/bin/irb:12:in `<main>'

I've checked permissions on the file/folder, and I'm running as Administrator in the CMD shell. The .tmp file is present in the folder, as is the target file "a.mp3", which is presumably the problem, right? But File.rename will overwrite a target file if it already exists, so this must be an open file handle then.

Addendum: I've checked to see if there's a file handle open, and "a.mp3" is open If I enter the "File.rename('.a.mp3.tmp', 'a.mp3') after the Mp3Info.open command it generates the same error. If I enter a different target filename. The rename operation succeeds. If I enter the "File.rename('.a.mp3.tmp', 'a.mp3') without running the Mp3Info.open command, it succeeds.

More Addendum: I installed an older version (0.6.16) and the error doesn't happen. But that's no good, because I get the character set encoding problem, that prompted me to upgrade in the first place.

densya203 commented 9 years ago

Hello, jrq.

I'm sorry, I messed up your topic. I'm not be used to use github. I can't understand why my commit is considered as changed all break code. (I used LF.) So, I gave up making Pull Request.

Anyway, please try my branch.

https://github.com/skult/ruby-mp3info/commit/a987e32f7d566c2f97de334421b93890547f519c

jrq commented 9 years ago

That seems to have fixed it. Although I now need to use "mp3.tag.title" instead of "mp3.title" to access the "title" property.

Thanks.

densya203 commented 9 years ago

need to use "mp3.tag.title" instead of "mp3.title" Year, I have realized that. Thanks!