Mercurial Hosting > luan
comparison lucene/src/luan/modules/lucene/Lucene.luan @ 746:293c397e8dee
improve zip
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 14 Jul 2016 19:36:02 -0600 |
parents | 01e68da6983b |
children | de2418d11786 |
comparison
equal
deleted
inserted
replaced
745:9c1f28b26395 | 746:293c397e8dee |
---|---|
3 local error = Luan.error | 3 local error = Luan.error |
4 local ipairs = Luan.ipairs or error() | 4 local ipairs = Luan.ipairs or error() |
5 local type = Luan.type or error() | 5 local type = Luan.type or error() |
6 local Html = require "luan:Html.luan" | 6 local Html = require "luan:Html.luan" |
7 local Io = require "luan:Io.luan" | 7 local Io = require "luan:Io.luan" |
8 local uri = Io.uri or error() | |
8 local String = require "luan:String.luan" | 9 local String = require "luan:String.luan" |
9 local matches = String.matches or error() | 10 local matches = String.matches or error() |
11 local Table = require "luan:Table.luan" | |
10 local LuceneIndex = require "java:luan.modules.lucene.LuceneIndex" | 12 local LuceneIndex = require "java:luan.modules.lucene.LuceneIndex" |
11 local NumberFieldParser = require "java:luan.modules.lucene.queryparser.NumberFieldParser" | 13 local NumberFieldParser = require "java:luan.modules.lucene.queryparser.NumberFieldParser" |
12 local StringFieldParser = require "java:luan.modules.lucene.queryparser.StringFieldParser" | 14 local StringFieldParser = require "java:luan.modules.lucene.queryparser.StringFieldParser" |
13 local SaneQueryParser = require "java:luan.modules.lucene.queryparser.SaneQueryParser" | 15 local SaneQueryParser = require "java:luan.modules.lucene.queryparser.SaneQueryParser" |
14 local Version = require "java:org.apache.lucene.util.Version" | 16 local Version = require "java:org.apache.lucene.util.Version" |
103 function index.zip(zip_file) | 105 function index.zip(zip_file) |
104 matches(zip_file,[[\.zip$]]) or error("file "..zip_file.." doesn't end with '.zip'") | 106 matches(zip_file,[[\.zip$]]) or error("file "..zip_file.." doesn't end with '.zip'") |
105 index.snapshot( function(dir,file_names) | 107 index.snapshot( function(dir,file_names) |
106 local t = {} | 108 local t = {} |
107 for _, file_name in ipairs(file_names) do | 109 for _, file_name in ipairs(file_names) do |
108 t[file_name] = "file:"..dir.."/"..file_name | 110 t[#t+1] = dir.."/"..file_name |
109 end | 111 end |
110 Io.zip(zip_file,t) | 112 local base = uri("file:"..dir).parent().to_string() |
113 uri(zip_file).zip(base,Table.unpack(t)) | |
111 end ) | 114 end ) |
112 end | 115 end |
113 | 116 |
114 return index | 117 return index |
115 end | 118 end |