1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.4.1.1'

This commit is contained in:
gnosygnu
2016-04-04 21:26:29 -04:00
parent baaef32df2
commit b2a06b8125
252 changed files with 2882 additions and 2118 deletions

View File

@@ -23,7 +23,7 @@ import gplx.fsdb.*; import gplx.fsdb.meta.*;
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.imgs.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.gui.*;
public class Xof_fsdb_mgr__sql implements Xof_fsdb_mgr, GfoInvkAble {
private boolean init = false; private boolean fsdb_enabled = false;
private Xow_repo_mgr repo_mgr; private Xof_url_bldr url_bldr; private final Xof_img_size img_size = new Xof_img_size();
private Xow_repo_mgr repo_mgr; private Xof_url_bldr url_bldr; private final Xof_img_size img_size = new Xof_img_size();
public Xof_bin_mgr Bin_mgr() {return bin_mgr;} private Xof_bin_mgr bin_mgr;
public Fsm_mnt_mgr Mnt_mgr() {return mnt_mgr;} private Fsm_mnt_mgr mnt_mgr = new Fsm_mnt_mgr();
public void Init_by_wiki(Xow_wiki wiki) {

View File

@@ -1,121 +0,0 @@
/*
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.files.origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.fsdb.*;
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
public class Xob_orig_tbl_bldr extends Xob_itm_basic_base implements Xob_cmd {
private Db_conn conn; private boolean schema_1;
public Xob_orig_tbl_bldr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_file_orig_reg;}
public void Cmd_init(Xob_bldr bldr) {}
public void Cmd_bgn(Xob_bldr bldr) {
Xof_fsdb_mode fsdb_mode = wiki.File__fsdb_mode();
fsdb_mode.Tid_v2_bld_y_();
wiki.Init_assert();
Fsdb_db_mgr db_core_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
this.schema_1 = db_core_mgr.File__schema_is_1();
conn = db_core_mgr.File__orig_tbl_ary()[gplx.fsdb.meta.Fsm_mnt_mgr.Mnt_idx_main].Conn();
Io_url make_db_url = Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir()).Url();
Sqlite_engine_.Db_attach(conn, "make_db", make_db_url.Raw());
}
public void Cmd_run() {Exec();}
public void Cmd_end() {}
public void Cmd_term() {}
private void Exec() {
String tbl_name = "orig_reg", fld_status = "orig_status";
if (schema_1) {
tbl_name = "wiki_orig";
fld_status = "status";
}
conn.Exec_sql_plog_txn("orig_wkr.deleting orig_reg" , String_.Format(Sql_delete_wiki_orig, tbl_name)); // always delete orig_reg, else will not pick up changed sizes / moved repos; DATE:2014-07-21
conn.Exec_sql_plog_txn("orig_wkr.inserting xfer direct" , String_.Format(Sql_create_xfer_direct, tbl_name, fld_status));
conn.Exec_sql_plog_txn("orig_wkr.inserting xfer redirect" , String_.Format(Sql_create_xfer_redirect, tbl_name, fld_status));
conn.Exec_sql_plog_txn("orig_wkr.inserting orig direct" , String_.Format(Sql_create_orig_direct, tbl_name, fld_status));
conn.Exec_sql_plog_txn("orig_wkr.inserting orig redirect" , String_.Format(Sql_create_orig_redirect, tbl_name, fld_status));
}
private static final String
Sql_delete_wiki_orig = "DELETE FROM {0};"
, Sql_create_xfer_direct = String_.Concat_lines_nl
( "INSERT INTO {0} "
, "(orig_ttl, {1}, orig_repo, orig_ext, orig_w, orig_h, orig_redirect)"
, "SELECT DISTINCT"
, " xfer.lnki_ttl"
, ", 1 --pass"
, ", xfer.orig_repo"
, ", xfer.lnki_ext"
, ", xfer.orig_w"
, ", xfer.orig_h"
, ", ''"
, "FROM make_db.xfer_regy xfer"
, " LEFT JOIN {0} cur ON xfer.lnki_ttl = cur.orig_ttl"
, "WHERE cur.orig_ttl IS NULL"
)
, Sql_create_xfer_redirect = String_.Concat_lines_nl
( "INSERT INTO {0} "
, "(orig_ttl, {1}, orig_repo, orig_ext, orig_w, orig_h, orig_redirect)"
, "SELECT DISTINCT"
, " xfer.orig_redirect_src"
, ", 1 --pass"
, ", xfer.orig_repo"
, ", xfer.lnki_ext"
, ", xfer.orig_w"
, ", xfer.orig_h"
, ", xfer.lnki_ttl"
, "FROM make_db.xfer_regy xfer"
, " LEFT JOIN {0} cur ON xfer.orig_redirect_src = cur.orig_ttl"
, "WHERE cur.orig_ttl IS NULL"
, "AND Coalesce(xfer.orig_redirect_src, '') != ''"
)
, Sql_create_orig_direct = String_.Concat_lines_nl
( "INSERT INTO {0} "
, "(orig_ttl, {1}, orig_repo, orig_ext, orig_w, orig_h, orig_redirect)"
, "SELECT DISTINCT"
, " orig.lnki_ttl"
, ", 0 --unknown"
, ", orig.orig_repo"
, ", orig.lnki_ext"
, ", orig.orig_w"
, ", orig.orig_h"
, ", ''"
, "FROM make_db.orig_regy orig"
, " LEFT JOIN {0} cur ON orig.lnki_ttl = cur.orig_ttl"
, "WHERE cur.orig_ttl IS NULL" // not already in orig_reg
, "AND orig.orig_repo IS NOT NULL" // not found in oimg_image.sqlite3
, "AND Coalesce(orig.orig_w , -1) != -1" // ignore entries that are either ext_id = 0 ("File:1") or don't have any width / height info (makes it useless); need to try to get again from wmf_api
, "AND Coalesce(orig.orig_redirect_ttl, '') == ''" // direct
)
, Sql_create_orig_redirect = String_.Concat_lines_nl
( "INSERT INTO {0} "
, "(orig_ttl, {1}, orig_repo, orig_ext, orig_w, orig_h, orig_redirect)"
, "SELECT DISTINCT"
, " orig.orig_redirect_ttl"
, ", 0 --unknown"
, ", orig.orig_repo"
, ", orig.lnki_ext"
, ", orig.orig_w"
, ", orig.orig_h"
, ", ''"
, "FROM make_db.orig_regy orig"
, " LEFT JOIN {0} cur ON orig.orig_redirect_ttl = cur.orig_ttl"
, "WHERE cur.orig_ttl IS NULL" // not already in orig_reg
, "AND orig.orig_repo IS NOT NULL" // not found in oimg_image.sqlite3
, "AND Coalesce(orig.orig_w, -1) != -1" // ignore entries that are either ext_id = 0 ("File:1") or don't have any width / height info (makes it useless); need to try to get again from wmf_api
, "AND Coalesce(orig.orig_redirect_ttl, '') != ''" // redirect
)
;
}