diff --git a/ModsListDownloader/lib/sqlite-jdbc-3.32.3.2.jar b/ModsListDownloader/lib/sqlite-jdbc-3.32.3.2.jar new file mode 100644 index 0000000..b6f55b7 Binary files /dev/null and b/ModsListDownloader/lib/sqlite-jdbc-3.32.3.2.jar differ diff --git a/ModsListDownloader/scripts/build.sh b/ModsListDownloader/scripts/build.sh index d946ce8..b495522 100755 --- a/ModsListDownloader/scripts/build.sh +++ b/ModsListDownloader/scripts/build.sh @@ -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 .. diff --git a/ModsListDownloader/src/downloader/Database.java b/ModsListDownloader/src/downloader/Database.java index 10b6a35..3e4d308 100644 --- a/ModsListDownloader/src/downloader/Database.java +++ b/ModsListDownloader/src/downloader/Database.java @@ -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"); diff --git a/ModsListDownloader/src/downloader/DatabaseVersionManager.java b/ModsListDownloader/src/downloader/DatabaseVersionManager.java index 9f09b2a..1bd627d 100644 --- a/ModsListDownloader/src/downloader/DatabaseVersionManager.java +++ b/ModsListDownloader/src/downloader/DatabaseVersionManager.java @@ -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); } diff --git a/ModsListDownloader/src/downloader/Main.java b/ModsListDownloader/src/downloader/Main.java index 905cf99..6f98d07 100644 --- a/ModsListDownloader/src/downloader/Main.java +++ b/ModsListDownloader/src/downloader/Main.java @@ -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": diff --git a/ModsListDownloader/src/downloader/ModUpdater.java b/ModsListDownloader/src/downloader/ModUpdater.java index 2380199..7307f1a 100644 --- a/ModsListDownloader/src/downloader/ModUpdater.java +++ b/ModsListDownloader/src/downloader/ModUpdater.java @@ -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();