[Groonga-commit] ranguba/chupa-text at 0556a72 [master] Release temporary data explicitly

Back to archive index
Sutou Kouhei null+****@clear*****
Mon Jun 10 12:32:26 JST 2019


Sutou Kouhei	2019-06-10 12:32:26 +0900 (Mon, 10 Jun 2019)

  Revision: 0556a72a8b7a518279e345ba706ce27fdd4fa10b
  https://github.com/ranguba/chupa-text/commit/0556a72a8b7a518279e345ba706ce27fdd4fa10b

  Message:
    Release temporary data explicitly

  Modified files:
    lib/chupa-text/data.rb
    lib/chupa-text/extractor.rb
    lib/chupa-text/file-content.rb
    lib/chupa-text/input-data.rb
    lib/chupa-text/virtual-content.rb
    lib/chupa-text/virtual-file-data.rb

  Modified: lib/chupa-text/data.rb (+3 -0)
===================================================================
--- lib/chupa-text/data.rb    2019-06-07 06:36:17 +0900 (ff2f8db)
+++ lib/chupa-text/data.rb    2019-06-10 12:32:26 +0900 (3e2c367)
@@ -162,6 +162,9 @@ module ChupaText
       yield(StringIO.new(body))
     end
 
+    def release
+    end
+
     def peek_body(size)
       _body = body
       return nil if _body.nil?

  Modified: lib/chupa-text/extractor.rb (+7 -2)
===================================================================
--- lib/chupa-text/extractor.rb    2019-06-07 06:36:17 +0900 (75f9fd1)
+++ lib/chupa-text/extractor.rb    2019-06-10 12:32:26 +0900 (f08034a)
@@ -90,11 +90,15 @@ module ChupaText
       if decomposer.nil?
         if target.text_plain?
           debug {"#{log_tag}[extract][text-plain]"}
-          yield(target.to_utf8_body_data)
+          utf8_data = target.to_utf8_body_data
+          yield(utf8_data)
+          utf8_data.release unless target == utf8_data
         else
           debug {"#{log_tag}[extract][decomposer] not found"}
           if target.text?
-            yield(target.to_utf8_body_data)
+            utf8_data = target.to_utf8_body_data
+            yield(utf8_data)
+            utf8_data.release unless target == utf8_data
           end
         end
       else
@@ -107,6 +111,7 @@ module ChupaText
               "<#{target.mime_type}> -> <#{decomposed.mime_type}>"
           end
           extract_recursive(decomposed, &block)
+          decomposed.release
         end
       end
     end

  Modified: lib/chupa-text/file-content.rb (+3 -0)
===================================================================
--- lib/chupa-text/file-content.rb    2019-06-07 06:36:17 +0900 (67a31fb)
+++ lib/chupa-text/file-content.rb    2019-06-10 12:32:26 +0900 (11c3672)
@@ -28,6 +28,9 @@ module ChupaText
       File.open(@path, "rb", &block)
     end
 
+    def release
+    end
+
     def body
       open do |file|
         file.read

  Modified: lib/chupa-text/input-data.rb (+4 -0)
===================================================================
--- lib/chupa-text/input-data.rb    2019-06-07 06:36:17 +0900 (db1ca9f)
+++ lib/chupa-text/input-data.rb    2019-06-10 12:32:26 +0900 (894cd76)
@@ -48,6 +48,10 @@ module ChupaText
       @content.open(&block)
     end
 
+    def release
+      @content.release
+    end
+
     private
     def download
       begin

  Modified: lib/chupa-text/virtual-content.rb (+8 -0)
===================================================================
--- lib/chupa-text/virtual-content.rb    2019-06-07 06:36:17 +0900 (6d063f2)
+++ lib/chupa-text/virtual-content.rb    2019-06-10 12:32:26 +0900 (6095f67)
@@ -56,6 +56,14 @@ module ChupaText
       end
     end
 
+    def release
+      @body = nil
+      if @file
+        @file.delete
+        @file = nil
+      end
+    end
+
     def body
       if @body
         @body

  Modified: lib/chupa-text/virtual-file-data.rb (+4 -0)
===================================================================
--- lib/chupa-text/virtual-file-data.rb    2019-06-07 06:36:17 +0900 (1f94196)
+++ lib/chupa-text/virtual-file-data.rb    2019-06-10 12:32:26 +0900 (85b9e22)
@@ -38,5 +38,9 @@ module ChupaText
     def open(&block)
       @content.open(&block)
     end
+
+    def release
+      @content.release
+    end
   end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190610/d2d4b78d/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index