ramaze锁上传文件?

时间:2012-04-30 20:26:38

标签: ruby rack ramaze

有没有其他人在Windows上遇到过Ramaze的文件锁定问题?我上传的所有文件都被锁定(我正在使用上传帮助程序)。

我正在使用 - Ruby 1.93 - Ramaze-2012.04.14 - Rack-1.4.1

谢谢!

1 个答案:

答案 0 :(得分:0)

回答我自己的问题。看起来像是ramaze / helper / upload.rb

中的罪魁祸首
@realfile = File.new(path) #--->this opens the uploaded/saved file, thus locking it

我用这个 -

修补了我的本地copy.rb副本
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

然后在你的来电者中,只需在保存后关闭文件,就像这样......

get_uploaded_files.each_pair{|k, v|
    v.save "upload/#{v.filename}"
    v.realfile.close #close the file handle
}

我很快就会提交补丁......