[Groonga-commit] ranguba/chupa-text at 70da5fc [master] virtual-content: fix open error

Back to archive index
Kouhei Sutou null+****@clear*****
Mon Mar 4 06:50:37 JST 2019


Kouhei Sutou	2019-03-04 06:50:37 +0900 (Mon, 04 Mar 2019)

  Revision: 70da5fc378c3e6a7e11b7b82f3836c941dfd2f71
  https://github.com/ranguba/chupa-text/commit/70da5fc378c3e6a7e11b7b82f3836c941dfd2f71

  Message:
    virtual-content: fix open error

  Modified files:
    lib/chupa-text/virtual-content.rb
    test/test-virtual-content.rb

  Modified: lib/chupa-text/virtual-content.rb (+3 -3)
===================================================================
--- lib/chupa-text/virtual-content.rb    2019-03-04 06:34:38 +0900 (92194a7)
+++ lib/chupa-text/virtual-content.rb    2019-03-04 06:50:37 +0900 (6d063f2)
@@ -32,8 +32,8 @@ module ChupaText
         end
       end
       @original_path = original_path
-      body = input.read(INLINE_MAX_SIZE) || ""
-      if body.bytesize < INLINE_MAX_SIZE
+      body = input.read(INLINE_MAX_SIZE + 1) || ""
+      if body.bytesize <= INLINE_MAX_SIZE
         @body = body
         @size =****@body*****
         @file = nil
@@ -50,7 +50,7 @@ module ChupaText
 
     def open(&block)
       if @body
-        super
+        yield(StringIO.new(@body))
       else
         File.open(path, "rb", &block)
       end

  Modified: test/test-virtual-content.rb (+2 -2)
===================================================================
--- test/test-virtual-content.rb    2019-03-04 06:34:38 +0900 (de9ba76)
+++ test/test-virtual-content.rb    2019-03-04 06:50:37 +0900 (4ccfc9e)
@@ -1,4 +1,4 @@
-# Copyright (C) 2013  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2013-2019  Kouhei Sutou <kou****@clear*****>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -53,7 +53,7 @@ class TestVirtualContent < Test::Unit::TestCase
 
   sub_test_case("large data") do
     def setup
-      @body = "X" * (ChupaText::VirtualContent::BUFFER_SIZE + 1)
+      @body = "X" * (ChupaText::VirtualContent::INLINE_MAX_SIZE + 1)
     end
 
     def test_size
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190304/22163948/attachment-0001.html>


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