debug
This commit is contained in:
Binary file not shown.
@@ -4,7 +4,7 @@ cd src
|
||||
|
||||
javac \
|
||||
-d ../objs\
|
||||
-cp ../lib/commons-compress-1.20.jar:../lib/gson-2.8.7.jar:../lib/gson-2.8.6.jar\
|
||||
-cp ../lib/commons-compress-1.20.jar:../lib/gson-2.8.7.jar:../lib/gson-2.8.6.jar:../lib/sqlite-jdbc-3.32.3.2.jar\
|
||||
downloader/*.java downloader/forgeSvc/*.java downloader/helper/*.java
|
||||
|
||||
cd ..
|
||||
|
||||
@@ -18,6 +18,10 @@ public class Database {
|
||||
Gson gson;
|
||||
|
||||
public Database() {
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
} catch (ClassNotFoundException e1) {} //it will crash anyway
|
||||
|
||||
this.connector = new DBConnector();
|
||||
try {
|
||||
this.connector.connect((new File("database.dat")).getAbsolutePath());
|
||||
@@ -30,7 +34,7 @@ public class Database {
|
||||
|
||||
private int findProjectBySlug(String slug, int ptype) {
|
||||
int pjId = -1;
|
||||
ResultSet rs = this.connector.executeRequest("select projectid from projects where type =" + ptype + " and slug LIKE \"%" + slug.trim().toLowerCase() + "\"%");
|
||||
ResultSet rs = this.connector.executeRequest("select projectid from projects where type =" + ptype + " and slug LIKE \"%" + slug.trim().toLowerCase() + "%\"");
|
||||
try {
|
||||
if (rs.next()) {
|
||||
pjId = rs.getInt("projectid");
|
||||
|
||||
@@ -13,7 +13,7 @@ import downloader.helper.HttpHelper;
|
||||
public class DatabaseVersionManager {
|
||||
|
||||
private String version;
|
||||
private static final String Iam = "DBUpdater";
|
||||
private static final String ME = "DBUpdater";
|
||||
|
||||
public DatabaseVersionManager() {
|
||||
try {
|
||||
@@ -26,32 +26,32 @@ public class DatabaseVersionManager {
|
||||
public void updateIfNeeded() {
|
||||
String latestVersion = fetchLatestVersion();
|
||||
|
||||
if( !version.equals(latestVersion) ) {
|
||||
Log.i(Iam, "new dbVersion avaliable downloading...");
|
||||
if( version == null || !latestVersion.equals(version) ) {
|
||||
Log.i(ME, "new dbVersion avaliable downloading...");
|
||||
downloadDatabase(latestVersion);
|
||||
} else {
|
||||
Log.i(Iam, "update to Date");
|
||||
Log.i(ME, "update to Date");
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadDatabase(String dbVersion) {
|
||||
Log.i(Iam, "fetching=" + "http://files.mcdex.net/data/mcdex-v5-" + dbVersion + ".dat.bz2");
|
||||
Log.i(ME, "fetching=" + "http://files.mcdex.net/data/mcdex-v5-" + dbVersion + ".dat.bz2");
|
||||
File archive;
|
||||
try {
|
||||
archive = HttpHelper.readFileFromUrl("http://files.mcdex.net/data/mcdex-v5-" + dbVersion + ".dat.bz2");
|
||||
} catch (MalformedURLException e) {
|
||||
Log.e(Iam, "Error invalid database download url");
|
||||
Log.e(ME, "Error invalid database download url");
|
||||
System.exit(1);
|
||||
//utile pour le lint
|
||||
return;
|
||||
}
|
||||
Log.i(Iam, "download finished");
|
||||
Log.i(Iam, "decompressing db");
|
||||
Log.i(ME, "download finished");
|
||||
Log.i(ME, "decompressing db");
|
||||
try {
|
||||
ArchiveHelper.decompressBz2(archive, "database.dat");
|
||||
archive.delete();
|
||||
} catch (IOException e) {
|
||||
Log.e(Iam, "[ERROR]cannot extract database");
|
||||
Log.e(ME, "[ERROR]cannot extract database");
|
||||
if(archive.exists()) archive.delete();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Main {
|
||||
String cmd = it.next();
|
||||
switch (cmd) {
|
||||
case "--check":
|
||||
System.out.println("--check is not avaliable")
|
||||
System.out.println("--check is not avaliable");
|
||||
checkingonly = true;
|
||||
continue;
|
||||
case "-t":
|
||||
|
||||
@@ -23,13 +23,14 @@ public class ModUpdater {
|
||||
public void update() {
|
||||
File modsList = new File("modpack.txt");
|
||||
|
||||
if(modsList.exists() && modsList.isFile()) {
|
||||
if(!(modsList.exists() && modsList.isFile())) {
|
||||
Log.e("Updater", "[ERROR]no mod file found exiting...");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
//parse and download
|
||||
try {
|
||||
//TODO: add threads
|
||||
BufferedReader in = new BufferedReader(new FileReader(modsList));
|
||||
while (in.ready()) {
|
||||
String line = in.readLine();
|
||||
|
||||
Reference in New Issue
Block a user