1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-03-11 19:53:07 +00:00

changed from Zlib::GzipWriter/Zlib::GzipReader to Zlib::Inflate/Zlib::Deflate

git-svn-id: http://redmine.rubyforge.org/svn/branches/work@315 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-03-08 18:47:39 +00:00
parent 47e4864314
commit 220f8a2135

View File

@ -30,11 +30,13 @@ class WikiContent < ActiveRecord::Base
def text=(plain)
case Setting.wiki_compression
when 'gzip'
gz = Zlib::GzipWriter.new(compressed = StringIO.new)
gz.write(plain)
gz.close
self.data = compressed.string
begin
self.data = Zlib::Deflate.deflate(plain, Zlib::BEST_COMPRESSION)
self.compression = 'gzip'
rescue
self.data = plain
self.compression = ''
end
else
self.data = plain
self.compression = ''
@ -43,12 +45,9 @@ class WikiContent < ActiveRecord::Base
end
def text
case compression
@text ||= case compression
when 'gzip'
gz = Zlib::GzipReader.new(StringIO.new(data))
plain = gz.read
gz.close
plain
Zlib::Inflate.inflate(data)
else
# uncompressed data
data