mirror of
https://github.com/redmine/redmine.git
synced 2026-05-07 15:36:48 +02: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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user