From: ara.t.howard@... Date: 2006-01-17T01:50:52+09:00 Subject: Re: FileUtils.mv does not unlink source file when moving over filesystem boundary On Mon, 16 Jan 2006, Pav Lucistnik wrote: > Hi, > > I found a bug in ruby 1.8.4 in FileUtils.mv() function. When moving a > file from one filesystem to another, it does not unlink the source file. > Ruby 1.8.2 worked fine. > > Patch against 1.8.4 release: > > --- lib/fileutils.rb.orig Sun Nov 20 02:23:41 2005 > +++ lib/fileutils.rb Mon Jan 16 02:08:47 2006 > @@ -501,6 +501,7 @@ > File.rename s, d > rescue Errno::EXDEV > copy_entry s, d, true > + File.unlink s > end > rescue SystemCallError eeks! this is terrible even with the fix. emulating mv with copy will undoubtedly blows up certain codes that assume files in a directory are not actively being written to. at minimum this code should do something like ... def transfer_entry s, d, hidden = true, ext = "tmp" dirname, basename = File.split d tmp = File.join dirname, "#{ '.' if hidden }#{ basename }.#{ ext }" copy_entry s, tmp, true File.rename tmp, d end ... File.rename s, d rescue Errno::EXDEV transfer_entry s, d File.unlink s end rescue SystemCallError ... to emulate mv with copy really is shocking. regards. -a -- strong and healthy, who thinks of sickness until it strikes like lightning? preoccupied with the world, who thinks of death, until it arrives like thunder? -- milarepa