长时间未手动清理过jar缓存将自动清理(自带md5除外);

pull/144/head
21561 1 year ago
parent 10c3ff3ab3
commit ca8eaae1b8
  1. 4
      app/src/main/java/com/github/catvod/crawler/JarLoader.java
  2. 2
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  3. 7
      app/src/main/java/com/github/tvbox/osc/util/FileUtils.java
  4. 2
      gradle.properties

@ -5,6 +5,7 @@ import android.util.Log;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.util.FileUtils;
import com.github.tvbox.osc.util.MD5;
import com.lzy.okgo.OkGo;
@ -127,7 +128,7 @@ public class JarLoader {
return classLoaders.get(key);
}
}else {
if (cache.exists()) {
if (cache.exists() && !FileUtils.isWeekAgo(cache)) {
loadClassLoader(cache.getAbsolutePath(), key);
return classLoaders.get(key);
}
@ -181,6 +182,7 @@ public class JarLoader {
DexClassLoader classLoader = jarKey.equals("main")? classLoaders.get("main"):loadJarInternal(jarUrl, jarMd5, jarKey);
if (classLoader == null) return new SpiderNull();
try {
Log.i("JarLoader", "echo-getSpider 加载spider: " + key);
Spider sp = (Spider) classLoader.loadClass("com.github.catvod.spider." + clsKey).newInstance();
sp.init(App.getInstance(), ext);
// if (!jar.isEmpty()) {

@ -321,7 +321,7 @@ public class ApiConfig {
return;
}
}else {
if (cache.exists()) {
if (cache.exists() && !FileUtils.isWeekAgo(cache)) {
if (jarLoader.load(cache.getAbsolutePath())) {
callback.success();
} else {

@ -132,6 +132,13 @@ public class FileUtils {
}
}
public static boolean isWeekAgo(File file)
{
long oneWeekMillis = 15L * 24 * 60 * 60 * 1000;
long timeDiff = System.currentTimeMillis() - file.lastModified();
return timeDiff > oneWeekMillis;
}
public static void deleteFile(File file) {
if (!file.exists()) return;
if (file.isFile()) {

@ -17,4 +17,4 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
IsDebug=true
org.gradle.jvmargs=-Xmx2048m --add-opens java.base/java.io=ALL-UNNAMED
#org.gradle.jvmargs=-Xmx2048m --add-opens java.base/java.io=ALL-UNNAMED

Loading…
Cancel
Save