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

Page_sync: Sync recently-created pages

This commit is contained in:
gnosygnu
2017-05-07 11:47:53 -04:00
parent 417fd8b990
commit bee71c22fe
11 changed files with 180 additions and 60 deletions

View File

@@ -369,6 +369,15 @@ public class Xowd_page_tbl implements Db_tbl {
.Exec_update()
;
}
public void Update__redirect(int redirect_to_id, int page_id) {
conn.Stmt_update(tbl_name, String_.Ary(fld_id), fld_is_redirect, fld_redirect_id)
.Val_int(fld_is_redirect, Bool_.Y_int)
.Val_int(fld_redirect_id, redirect_to_id)
.Crt_int(fld_id, page_id)
.Exec_update()
;
}
public void Delete(int page_id) {
Gfo_usr_dlg_.Instance.Log_many("", "", "db.page: delete started: page_id=~{0}", page_id);
conn.Stmt_delete(tbl_name, fld_id).Crt_int(fld_id, page_id).Exec_delete();

View File

@@ -57,6 +57,9 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
db_mgr.Core_data_mgr().Tbl__page().Select_in__ns_ttl(cancelable, rv, db_mgr.Wiki().Ns_mgr(), fill_idx_fields_only, bgn, end);
}
public void Load_page(Xowd_page_itm rv, Xow_ns ns) {
if (rv.Text_db_id() == -1) return; // NOTE: page_sync will create pages with -1 text_db_id; DATE:2017-05-06
// get text
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id_or_fail(rv.Text_db_id()).Tbl__text();
byte[] text_bry = text_tbl.Select(rv.Id());
rv.Text_(text_bry);

View File

@@ -20,11 +20,10 @@ import gplx.xowa.addons.wikis.pages.syncs.core.*;
import gplx.xowa.wikis.data.tbls.*;
public class Xowe_page_mgr {
private final Xowe_wiki wiki;
private final Xosync_read_mgr read_mgr = new Xosync_read_mgr();
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
private final Gfo_qarg_mgr tmp_qarg_mgr = new Gfo_qarg_mgr();
public Xowe_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
public Xosync_read_mgr Sync_mgr() {return read_mgr;}
public Xosync_read_mgr Sync_mgr() {return read_mgr;} private final Xosync_read_mgr read_mgr = new Xosync_read_mgr();
public void Init_by_wiki(Xowe_wiki wiki) {
read_mgr.Init_by_wiki(wiki);
}
@@ -64,10 +63,13 @@ public class Xowe_page_mgr {
Wait_for_popups(wiki.App());
// auto-update
if (read_mgr.Auto_update(wiki, page, ttl)) {
// page-sync occurred; reload metadata, especially to pick up Html_db_id; DATE:2017-03-13
Xoa_ttl redirect_ttl = read_mgr.Auto_update(wiki, page, ttl);
if (redirect_ttl != null) {
// page-sync occurred; update ttl to handle any redirection; DATE:2017-05-07
ttl = redirect_ttl;
// reload metadata, needed to pick up Html_db_id; DATE:2017-03-13
page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
ttl = page.Ttl(); // note that Load_page_and_parse can redirect ttl; EX: Special:Random -> A; DATE:2017-01-05
}
// load from html_db