Has anyone else encountered a file locking issue with Ramaze on Windows? All my uploaded files are being locked (I'm using the upload helper btw).
I'm using - Ruby 1.93 - Ramaze-2012.04.14 - Rack-1.4.1
Thanks!
Answering my own question. Looks like the culprit's this line in ramaze/helper/upload.rb
@realfile = File.new(path) #--->this opens the uploaded/saved file, thus locking it
I patched my local copy of upload.rb with this --
class UploadedFile
include Ramaze::Traited
# Suggested file name
# @return [String]
attr_reader :filename
# MIME-type
# @return [String]
attr_reader :type
# Saved file object
# @return [File]
attr_reader :realfile #---> expose the variable so we can close it from the caller
And then in your caller, simply close the file after you save it, like so...
get_uploaded_files.each_pair{|k, v|
v.save "upload/#{v.filename}"
v.realfile.close #close the file handle
}
I will be submitting a patch soon...