2015-07-13 01:10:02 +00:00
/ *
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 ; import gplx.* ;
2015-10-19 02:17:57 +00:00
import gplx.xowa.apps.apis.xowa.bldrs.imports.* ; import gplx.xowa.wikis.data.* ; import gplx.xowa.bldrs.infos.* ;
2015-09-21 03:43:51 +00:00
public class Xowe_wiki_ {
2015-07-13 01:10:02 +00:00
public static void Create ( Xowe_wiki wiki , long src_fil_len , String src_fil_name ) {
wiki . Db_mgr_create_as_sql ( ) ; // create db_mgr as sql
Xoapi_import import_api = wiki . Appe ( ) . Api_root ( ) . Bldr ( ) . Wiki ( ) . Import ( ) ;
Xowd_core_db_props db_mgr_props = import_api . New_props ( wiki . Domain_str ( ) , src_fil_len ) ;
Xob_info_session info_session = Xob_info_session . new_ ( import_api . User_name ( ) , wiki . Domain_str ( ) , src_fil_name ) ;
2016-06-20 03:58:10 +00:00
wiki . Data__core_mgr ( ) . Init_by_make ( db_mgr_props , info_session ) ; // make core_db
}
public static void Rls_mem_if_needed ( Xowe_wiki wiki ) {
Xoae_app app = wiki . Appe ( ) ;
2016-08-30 03:31:58 +00:00
if ( gplx . core . envs . Runtime_ . Memory_free ( ) < app . Sys_cfg ( ) . Free_mem_when ( ) ) // check if low in memory
2016-07-26 01:59:51 +00:00
Xowe_wiki_ . Rls_mem ( wiki , false ) ; // clear caches (which will clear bry_bfr_mkr)
else // not low in memory
wiki . Utl__bfr_mkr ( ) . Clear ( ) ; // clear bry_bfr_mkr only; NOTE: call before page parse, not when page is first added, else threading errors; DATE:2014-05-30
2016-06-20 03:58:10 +00:00
}
public static void Rls_mem ( Xowe_wiki wiki , boolean clear_ctx ) {
wiki . Appe ( ) . Free_mem ( clear_ctx ) ;
wiki . Cache_mgr ( ) . Free_mem_all ( ) ;
2016-07-11 03:35:32 +00:00
wiki . Parser_mgr ( ) . Scrib ( ) . Core_term ( ) ;
2015-07-13 01:10:02 +00:00
}
}