Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents ee4926d + 2aff86e commit 9c5a7e8fa8d8ab6730cddcedf78ec06c6341489f @ongaeshi committed Aug 11, 2011
Showing with 70 additions and 31 deletions.
  1. +12 −0 HISTORY.rdoc
  2. +1 −1 VERSION
  3. +1 −1 bin/milk
  4. +54 −28 lib/milkode/cdstk/cdstk.rb
  5. +1 −0 lib/milkode/cdstk/cli_cdstk.rb
  6. +1 −1 lib/milkode/cdweb/app.rb
View
@@ -1,3 +1,15 @@
+=== 0.2.1 2011/08/12
+
+Milkode repository is version up.
+Please rebuild repository.
+
+ milk rebuild
+
+* Support AutoPagerize. (thanks awasira)
+* 'documents' table type change, 'Groonga::Array -> Groonga:: Hash'.
+ * 'milk update' faster (thanks kou)
+ * Issues#6 CentOS 5.5 (32bit) in 'milk update' fails (thanks yoshikaw)
+
=== 0.2.0 2011/08/10
* Issues#4 Bug fix, wrong display of search results. (thanks rakkoyaku, ryo)
View
@@ -1 +1 @@
-0.2.0
+0.2.1
View
@@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/cdstk/cli_cdstk'
-Version = "0.2.0"
+Version = "0.2.1"
Milkode::CLI_Cdstk.execute(STDOUT, ARGV)
View
@@ -55,6 +55,10 @@ def init
end
end
+ def compatible?
+ db_open(db_file)
+ end
+
def update(args = nil)
print_result do
yaml = yaml_load
@@ -251,6 +255,10 @@ def pwd(options)
end
def cleanup(options)
+ # 互換性テスト
+ db_open(db_file)
+
+ # cleanup開始
if (options[:force] or yes_or_no("cleanup contents? (yes/no)"))
print_result do
# yamlファイルのクリーンアップ
@@ -366,37 +374,44 @@ def db_create(filename)
unless dbfile.exist?
Groonga::Database.create(:path => dbfile.to_s)
- Groonga::Schema.define do |schema|
- schema.create_table("documents") do |table|
- table.string("path")
- table.string("shortpath")
- table.text("content")
- table.time("timestamp")
- table.text("suffix")
- end
-
- schema.create_table("terms",
- :type => :patricia_trie,
- :key_normalize => true,
- :default_tokenizer => DEFAULT_TOKENIZER) do |table|
- table.index("documents.path", :with_position => true)
- table.index("documents.shortpath", :with_position => true)
- table.index("documents.content", :with_position => true)
- table.index("documents.suffix", :with_position => true)
- end
- end
+ db_define
@out.puts "create : #{filename} created."
else
@out.puts "message : #{filename} already exist."
end
end
+ def db_define
+ Groonga::Schema.define do |schema|
+ schema.create_table("documents", :type => :hash) do |table|
+ table.string("path")
+ table.string("shortpath")
+ table.text("content")
+ table.time("timestamp")
+ table.text("suffix")
+ end
+
+ schema.create_table("terms",
+ :type => :patricia_trie,
+ :key_normalize => true,
+ :default_tokenizer => DEFAULT_TOKENIZER) do |table|
+ table.index("documents.path", :with_position => true)
+ table.index("documents.shortpath", :with_position => true)
+ table.index("documents.content", :with_position => true)
+ table.index("documents.suffix", :with_position => true)
+ end
+ end
+ end
+
def db_open(filename)
dbfile = Pathname(File.expand_path(filename))
if dbfile.exist?
+ # データベースを開く
Groonga::Database.open(dbfile.to_s)
- # @out.puts "open : #{dbfile} open."
+
+ # 互換性テスト
+ db_compatible?
else
raise "error : #{dbfile.to_s} not found!!"
end
@@ -429,18 +444,14 @@ def db_add_file(stdout, filename, shortpath)
# 検索するデータベース
documents = Groonga::Context.default["documents"]
- # 既に登録されているファイルならばそれを上書き、そうでなければ新規レコードを作成
- _documents = documents.select do |record|
- record["path"] == values[:path]
- end
-
+ record = documents[ values[:path] ]
isNewFile = false
- if _documents.size.zero?
- document = documents.add
+ unless record
+ document = documents.add(values[:path])
isNewFile = true
else
- document = _documents.to_a[0].key
+ document = record
end
# タイムスタンプが新しければデータベースに格納
@@ -514,5 +525,20 @@ def error_alert(msg)
@out.puts "[fatal] #{msg}"
end
+ def db_compatible?
+ begin
+ db_define
+ rescue Groonga::Schema::Error => e
+ puts <<EOF
+Milkode repository is old -> #{db_dir_expand}.
+Please rebuild repository,
+
+ milk rebuild
+
+See 'milk --help' or http://milkode.ongaeshi.me .
+EOF
+ exit -1
+ end
+ end
end
end
@@ -70,6 +70,7 @@ def self.execute(stdout, arguments=[])
when 'dump'
obj.dump
when 'web'
+ obj.compatible?
Milkode::CLI_Cdweb.execute_with_options(stdout, suboptions[subcommand])
end
else
View
@@ -18,7 +18,7 @@
set :haml, :format => :html5
get '/' do
- @version = "0.2.0"
+ @version = "0.2.1"
@package_num = Database.instance.fileList('').size
@file_num = Database.instance.fileNum
haml :index

0 comments on commit 9c5a7e8

Please sign in to comment.