public static Xow_import_doc New(IoItmDir owner_dir, byte[] dir_cmd) { List_adp sub_list = List_adp_.New(); New_subs(owner_dir.Url(), sub_list, owner_dir.SubDirs(), dir_cmd); New_subs(owner_dir.Url(), sub_list, owner_dir.SubFils(), Bry_.Empty); Xow_import_doc[] subs = (Xow_import_doc[]) sub_list.To_ary_and_clear(Xow_import_doc.class); return new Xow_import_doc( Bool_.Y, Bool_.N, 0, owner_dir.Url().OwnerDir().RawBry(), owner_dir.Url().RawBry(), Bry_.new_u8(owner_dir.Name()), Bry_.Empty, Bry_.Empty, dir_cmd, subs); }
@Override public void Cmd_run() { Init_bldr_bmks(); this.time_bgn = System_.Ticks(); int total_pending = Xob_xfer_regy_tbl.Select_total_pending(bldr_conn); // if (total_pending > 250000 && src_bin_mgr__fsdb_version == null) usr_dlg.Note_many("", "", "total pending: ~{0}", total_pending); List_adp list = List_adp_.New(); boolean loop = true; while (loop) { byte rslt = Select_fsdb_itms(list); switch (rslt) { case Select_rv_stop: if (bin_db_mgr.Tier_id_is_last(tier_id_val)) loop = false; else { ++tier_id_val; page_id_val = 0; continue; } break; case Select_rv_next_page: ++page_id_val; lnki_id_val = 0; continue; case Select_rv_process: break; } if (!loop) break; // no more ttls found int len = list.Count(); usr_dlg.Prog_many("", "", "fetched pages: ~{0}", len); for (int i = 0; i < len; ++i) { Xodb_tbl_oimg_xfer_itm fsdb = (Xodb_tbl_oimg_xfer_itm) list.Get_at(i); Download_itm(fsdb); if (exit_now || exec_count >= exec_count_max || exec_fail >= exec_fail_max || page_id_val >= page_id_end) { this.Txn_sav(); return; } } } exec_done = true; }
private static void New_subs(Io_url owner_dir, List_adp list, IoItmList subs, byte[] dir_cmd) { subs.Sort(); int len = subs.Len(); int list_total = list.Len(); byte[] owner_dir_bry = owner_dir.RawBry(); for (int i = 0; i < len; ++i) { IoItm_base src = (IoItm_base) subs.Get_at(i); Xow_import_doc trg = null; if (src.Type_dir()) { byte[] trg_url = src.Url().RawBry(); trg = new Xow_import_doc( Bool_.Y, Bool_.N, list_total + i, owner_dir_bry, trg_url, Bry_.new_u8(src.Url().NameAndExt_noDirSpr()), Bry_.Empty, Bry_.Empty, dir_cmd, Ary_empty); } else { IoItmFil src_as_fil = (IoItmFil) src; String size_str = Io_size_.To_str(src_as_fil.Size(), "#,###"); boolean is_xowa_core = gplx.xowa.wikis.data.Xow_db_file__core_.Is_core_fil_name( owner_dir.NameOnly(), src.Url().NameAndExt()); trg = new Xow_import_doc( Bool_.N, is_xowa_core, list_total + i, owner_dir_bry, src.Url().RawBry(), Bry_.new_u8(src.Name()), Bry_.new_u8(src_as_fil.ModifiedTime().XtoStr_fmt("yyyy-MM-dd")), Bry_.new_u8(size_str), dir_cmd, Ary_empty); } list.Add(trg); } }
public void Fsdb_search_by_list( List_adp itms, Xow_wiki cur_wiki, Xoa_page page, Xog_js_wkr js_wkr) { if (!fsdb_enabled) return; int len = itms.Count(); Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance; Xow_wiki wiki = page.Commons_mgr().Source_wiki_or(cur_wiki); Xou_cache_mgr cache_mgr = wiki.App().User().User_db_mgr().Cache_mgr(); for (int i = 0; i < len; i++) { if (usr_dlg.Canceled()) return; Xof_fsdb_itm fsdb = (Xof_fsdb_itm) itms.Get_at(i); if (fsdb.Hdump_mode() == Xof_fsdb_itm.Hdump_mode__null) { Xof_orig_itm orig = wiki.File__orig_mgr().Find_by_ttl_or_null(fsdb.Lnki_ttl(), i, len); if (orig != Xof_orig_itm.Null) { // orig exists; gplx.xowa.files.repos.Xof_repo_itm repo = wiki.File__repo_mgr().Get_trg_by_id_or_null(orig.Repo(), fsdb.Lnki_ttl(), Bry_.Empty); if (repo == null) continue; fsdb.Init_at_orig( orig.Repo(), repo.Wiki_domain(), orig.Ttl(), orig.Ext(), orig.W(), orig.H(), orig.Redirect()); } } fsdb.Init_at_xfer(i, len); Xof_file_wkr.Show_img( fsdb, usr_dlg, wiki.File__bin_mgr(), wiki.File__mnt_mgr(), cache_mgr, wiki.File__repo_mgr(), js_wkr, img_size, url_bldr, page); } }
private byte Select_fsdb_itms(List_adp list) { list.Clear(); boolean pages_found = false, links_found = false; DataRdr rdr = Xob_xfer_regy_tbl.Select_by_tier_page(bldr_conn, tier_id_val, page_id_val, select_interval); try { while (rdr.MoveNextPeer()) { pages_found = true; // at least one page found; set true Xodb_tbl_oimg_xfer_itm itm = Xodb_tbl_oimg_xfer_itm.new_rdr_(rdr); if (itm.Lnki_page_id() == page_id_val // same page_id && itm.Lnki_id() <= lnki_id_val // ... but lnki_id < last ) continue; // ... ignore; note that select is by page_id, not page_id + link_id; needed // else restarts would not resume exactly at same point; links_found = true; list.Add(itm); } } finally { rdr.Rls(); } if (pages_found && !links_found) return Select_rv_next_page; // pages found, but all links processed else if (!pages_found) return Select_rv_stop; // no more pages found else return Select_rv_process; // pages and links found }