mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Add option to make_cmd to not delete all html databases
This commit is contained in:
parent
9165ceef79
commit
af8306ae9b
@ -25,13 +25,9 @@ class Xomp_html_db_wtr {
|
||||
private int prv_ns_id = -1;
|
||||
private Xow_db_file html_db; private Xowd_html_tbl html_tbl;
|
||||
private Xob_ns_file_itm ns_itm;
|
||||
public Xomp_html_db_wtr(Xowe_wiki wiki, boolean reset_html_dbs) {
|
||||
public Xomp_html_db_wtr(Xowe_wiki wiki) {
|
||||
this.wiki = wiki; this.db_mgr = wiki.Data__core_mgr();
|
||||
this.len_max = wiki.Appe().Api_root().Bldr().Wiki().Import().Html_db_max();
|
||||
|
||||
// delete all existing tbls
|
||||
if (!db_mgr.Props().Layout_html().Tid_is_all())
|
||||
wiki.Data__core_mgr().Dbs__delete_by_tid(Xow_db_file_.Tid__html_data);
|
||||
}
|
||||
public int Cur_db_id() {return html_db.Id();}
|
||||
public Xowd_html_tbl Tbls__get_or_new(int ns_id, long html_len) {
|
||||
@ -88,4 +84,20 @@ class Xomp_html_db_wtr {
|
||||
Db_attach_mgr attach_mgr = new Db_attach_mgr(db_mgr.Db__core().Conn(), new Db_attach_itm("html_db", html_db.Conn()));
|
||||
attach_mgr.Exec_sql_w_msg("updating page_ids: " + Int_.To_str(html_db.Id()), sql);
|
||||
}
|
||||
public static void Delete_html_dbs(Xowe_wiki wiki) {
|
||||
// run only for few /lot
|
||||
Xow_db_mgr db_mgr = wiki.Data__core_mgr();
|
||||
if (db_mgr.Props().Layout_html().Tid_is_all()) return;
|
||||
|
||||
// loop thru dbs and delete files
|
||||
int len = db_mgr.Dbs__len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_db_file db_file = db_mgr.Dbs__get_at(i);
|
||||
if (db_file.Tid() == Xow_db_file_.Tid__html_data)
|
||||
Io_mgr.Instance.DeleteFil(db_file.Url());
|
||||
}
|
||||
|
||||
// remove from xowa_db
|
||||
db_mgr.Dbs__delete_by_tid(Xow_db_file_.Tid__html_data);
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Xomp_make_cmd extends Xob_cmd__base {
|
||||
private final Xomp_make_cmd_cfg cfg = new Xomp_make_cmd_cfg();
|
||||
public Xomp_make_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
wiki.Init_assert();
|
||||
new Xomp_make_html().Exec(wiki);
|
||||
new Xomp_make_html().Exec(wiki, cfg);
|
||||
new Xomp_make_lnki().Exec(wiki, 10000);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__cfg)) return cfg;
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
} private static final String Invk__cfg = "cfg";
|
||||
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;} private static final String BLDR_CMD_KEY = "wiki.mass_parse.make";
|
||||
public static final Xob_cmd Prototype = new Xomp_make_cmd(null, null);
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
public class Xomp_make_cmd_cfg implements Gfo_invk {
|
||||
public boolean Delete_html_dbs() {return delete_html_dbs;} private boolean delete_html_dbs = true;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__delete_html_dbs_)) delete_html_dbs = m.ReadYn("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk__delete_html_dbs_ = "delete_html_dbs_"
|
||||
;
|
||||
}
|
@ -20,7 +20,7 @@ import gplx.core.brys.*;
|
||||
import gplx.dbs.*; import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.addons.bldrs.mass_parses.dbs.*;
|
||||
class Xomp_make_html {
|
||||
private final Int_flag_bldr src_body_flag_bldr = Xowd_html_tbl.Make_body_flag_bldr();
|
||||
public void Exec(Xowe_wiki wiki) {
|
||||
public void Exec(Xowe_wiki wiki, Xomp_make_cmd_cfg cfg) {
|
||||
// init
|
||||
Xomp_mgr_db mgr_db = Xomp_mgr_db.New__load(wiki);
|
||||
Db_conn mgr_conn = mgr_db.Conn();
|
||||
@ -34,7 +34,8 @@ class Xomp_make_html {
|
||||
|
||||
// init more
|
||||
Xomp_html_db_rdr html_db_rdr = new Xomp_html_db_rdr(wiki);
|
||||
Xomp_html_db_wtr html_db_wtr = new Xomp_html_db_wtr(wiki, true);
|
||||
Xomp_html_db_wtr html_db_wtr = new Xomp_html_db_wtr(wiki);
|
||||
if (cfg.Delete_html_dbs()) Xomp_html_db_wtr.Delete_html_dbs(wiki);
|
||||
Xowd_html_row src_row = new Xowd_html_row();
|
||||
|
||||
// loop xomp|page and generate html dbs
|
||||
|
Loading…
Reference in New Issue
Block a user