From: Jeremy Bopp Date: 2010-10-05T22:39:08+09:00 Subject: Re: how do i delete files in particular directoryin ruby ??? On 10/5/2010 8:10 AM, Amit Tomar wrote: > Jeremy Bopp wrote: >> On 10/05/2010 07:31 AM, Amit Tomar wrote: >>>> FileUtils.rm_r and FileUtils.rm_rf emulate that program when using the >>> but am on windows side and can i delete those files also that are in use >>> means when am trying to manually delete particular file(mongrel temp >>> file)am getting error message can't delete files its in use >>> but usinf -rf can i delete those files also?? >> >> You're bumping into a common limitation of Windows, sadly. It takes >> some special tricks to fake deleting a file which is in use on Windows, >> and I'm not certain that FileUtils has been written to perform such >> tricks. Note that I did say "fake deleting" since the file is not >> really deleted until it is no longer in use. It's just cleverly moved >> and hidden from what I understand. >> >> Cygwin and the Cygwin build of Ruby should be able to do this for you, >> but you are doing something which is not normal for Windows. Why do you >> want to delete this temporary file while Mongrel is running in the first >> place? >> >> -Jeremy > > Yaa Jeremy i really need do delete those file.. > > In my rails application i am uploading some large file (2gb) and while > doing mongrel +ruby temp file is being created ,ruby temp files is not > the problem because they are garbaselly collecting after upload but > mongerl temprary files are sitll holding memory > that is why iw ant to delete them only after i restart mongerl i get > ridoff those temp files but i don't restart server Unfortunately, either Mongrel or your application is still using those files; otherwise, you would be able to delete the files on Windows. Even on non-Windows then, deleting the files won't reclaim the space until after the program with the open file handles stops and releases the files, so if consumption of disk space is your concern, you need to find a way to close those files even if you manage to delete them. I'm not familiar enough with Mongrel to give anything more than general suggestions, so take this for what it's worth. Confirm that your application is not causing these files to be opened and never closed by way of a long-lived File instance referenced in one of your objects. Maybe you can boil down your application to just this upload feature and use that as a simple test case to prove that Mongrel is the one holding onto these files. If the temporary file really is created by Mongrel itself, perhaps there is a configuration option to tell Mongrel to periodically dump its temporary files and create new ones. -Jeremy