mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.2.1
This commit is contained in:
37
400_xowa/src/gplx/xowa/apps/setups/Xoa_setup_mgr.java
Normal file
37
400_xowa/src/gplx/xowa/apps/setups/Xoa_setup_mgr.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.apps.setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.xowa.apps.versions.*;
|
||||
public class Xoa_setup_mgr {
|
||||
public static void Delete_old_files(Xoae_app app) {
|
||||
String version_previous = app.Api_root().App().Env().Version_previous();
|
||||
Gfo_usr_dlg usr_dlg = app.Usr_dlg();
|
||||
Io_url root_dir = app.Fsys_mgr().Root_dir();
|
||||
Delete_old_dir(usr_dlg, version_previous, "1.8.2.1" , root_dir.GenSubDir_nest("user", "anonymous", "lang"));
|
||||
Delete_old_dir(usr_dlg, version_previous, "1.8.2.1" , root_dir.GenSubDir_nest("user", "anonymous", "wiki", "#cfg"));
|
||||
Delete_old_dir(usr_dlg, version_previous, "1.10.2.1" , root_dir.GenSubDir_nest("bin", "any", "javascript"));
|
||||
Delete_old_dir(usr_dlg, version_previous, "1.10.2.1" , root_dir.GenSubDir_nest("bin", "any", "xowa", "html", "modules"));
|
||||
}
|
||||
@gplx.Internal protected static void Delete_old_dir(Gfo_usr_dlg usr_dlg, String version_prv, String version_del, Io_url dir) {
|
||||
if (Xoa_version_.Compare(version_prv, version_del) != CompareAble_.Less) return;
|
||||
usr_dlg.Log_many("", "", "setup:checking if dir exists: version_prv=~{0} version_del=~{1} dir=~{2}", version_prv, version_del, dir.Raw());
|
||||
if (!Io_mgr.I.ExistsDir(dir)) return;
|
||||
usr_dlg.Log_many("", "", "setup:deleting dir", version_prv, version_del, dir.Raw());
|
||||
Io_mgr.I.DeleteDirDeep(dir);
|
||||
}
|
||||
}
|
||||
36
400_xowa/src/gplx/xowa/apps/setups/Xoa_setup_mgr_tst.java
Normal file
36
400_xowa/src/gplx/xowa/apps/setups/Xoa_setup_mgr_tst.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
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.apps.setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_setup_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoa_setup_mgr_fxt fxt = new Xoa_setup_mgr_fxt();
|
||||
@Test public void Compare() {
|
||||
fxt.Test_delete_old_dir("mem/dir/", "1.8.1.1" , "1.8.2.1", Bool_.Y); // version is earlier than checkpoint; delete
|
||||
fxt.Test_delete_old_dir("mem/dir/", "1.8.2.1" , "1.8.2.1", Bool_.N); // version is not earlier than checkpoint; don't delete
|
||||
fxt.Test_delete_old_dir("mem/dir/", "" , "1.8.2.1", Bool_.Y); // version is empty; delete;
|
||||
}
|
||||
}
|
||||
class Xoa_setup_mgr_fxt {
|
||||
public void Clear() {}
|
||||
public void Test_delete_old_dir(String dir_str, String version_prv, String version_del, boolean expd) {
|
||||
Io_url dir = Io_url_.new_fil_(dir_str);
|
||||
Io_mgr.I.CreateDirIfAbsent(dir);
|
||||
Xoa_setup_mgr.Delete_old_dir(Gfo_usr_dlg_.Noop, version_prv, version_del, dir);
|
||||
Tfds.Eq(expd, !Io_mgr.I.ExistsDir(dir), version_prv + "|" + version_del);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user