Mercurial Hosting > luan
comparison src/luan/modules/lucene/Lucene.luan @ 1365:6617763dfd76
fix logging and lucene backup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 12 Jun 2019 22:16:10 -0600 |
parents | 8d95711f6615 |
children | 836e00bf7ce2 |
comparison
equal
deleted
inserted
replaced
1364:45363886f256 | 1365:6617763dfd76 |
---|---|
2 local Luan = require "luan:Luan.luan" | 2 local Luan = require "luan:Luan.luan" |
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 set_metatable = Luan.set_metatable or error() | 6 local set_metatable = Luan.set_metatable or error() |
7 local Boot = require "luan:Boot.luan" | |
7 local Html = require "luan:Html.luan" | 8 local Html = require "luan:Html.luan" |
8 local Io = require "luan:Io.luan" | 9 local Io = require "luan:Io.luan" |
9 local uri = Io.uri or error() | 10 local uri = Io.uri or error() |
10 local String = require "luan:String.luan" | 11 local String = require "luan:String.luan" |
11 local matches = String.matches or error() | 12 local matches = String.matches or error() |
136 local cmd = "zip "..zip_path.." "..dir_name.."/"..file_name | 137 local cmd = "zip "..zip_path.." "..dir_name.."/"..file_name |
137 Io.uri("os:"..cmd,options).read_text() | 138 Io.uri("os:"..cmd,options).read_text() |
138 end | 139 end |
139 end ) | 140 end ) |
140 end | 141 end |
142 index.zip = Boot.no_security(index.zip) | |
141 | 143 |
142 function index.restore(zip_file) | 144 function index.restore(zip_file) |
143 java_index.run_in_lock( function() | 145 java_index.run_in_lock( function() |
144 local lucene_dir = uri("file:"..index.dir) | 146 local lucene_dir = uri("file:"..index.dir) |
145 local before_restore = lucene_dir.parent().child("before_restore.zip") | 147 local before_restore = lucene_dir.parent().child("before_restore.zip") |
148 lucene_dir.delete() | 150 lucene_dir.delete() |
149 Io.uri("os:unzip "..zip_file.canonical().to_string(),{dir=lucene_dir.parent()}).read_text() | 151 Io.uri("os:unzip "..zip_file.canonical().to_string(),{dir=lucene_dir.parent()}).read_text() |
150 java_index.reopen() | 152 java_index.reopen() |
151 end ) | 153 end ) |
152 end | 154 end |
155 index.restore = Boot.no_security(index.restore) | |
153 | 156 |
154 local function multi_error() | 157 local function multi_error() |
155 error "multiple lucene instances" | 158 error "multiple lucene instances" |
156 end | 159 end |
157 | 160 |