refactor + cache de la bdd

This commit is contained in:
marc barbier
2021-01-13 23:41:32 +01:00
parent 568e577173
commit 3d6224e3af
8 changed files with 205 additions and 140 deletions
+39
View File
@@ -0,0 +1,39 @@
package downloader;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipFile;
public class IntegrityChecker {
public static String[] fileList;
public IntegrityChecker()
{
fileList = new File("mods").list();
}
public void checkAndDelete(File modToDownload, String slug) {
if (modToDownload.exists()) {
try {
//si sa balance une exception sa veut dire que le jar n'est pas lisible
new ZipFile(modToDownload).close();
} catch (IOException e) {
Log.i("integrityChecker","Corruption detected redownloading");
modToDownload.delete();
return;
}
for (String s : fileList) {
if (s.contains(slug)) {
if (!modToDownload.getName().contains(s)) {
new File(s).delete();
Log.i("integrityChecker","Corruption detected redownloading");
}
return;
}
}
}
}
}