diff --git a/app/src/main/java/com/github/catvod/crawler/JarLoader.java b/app/src/main/java/com/github/catvod/crawler/JarLoader.java index daf07be6..fa9775d3 100644 --- a/app/src/main/java/com/github/catvod/crawler/JarLoader.java +++ b/app/src/main/java/com/github/catvod/crawler/JarLoader.java @@ -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()) { diff --git a/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java b/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java index e39caa50..967214ed 100644 --- a/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java +++ b/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java @@ -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 { diff --git a/app/src/main/java/com/github/tvbox/osc/util/FileUtils.java b/app/src/main/java/com/github/tvbox/osc/util/FileUtils.java index e72cbba5..608d1295 100644 --- a/app/src/main/java/com/github/tvbox/osc/util/FileUtils.java +++ b/app/src/main/java/com/github/tvbox/osc/util/FileUtils.java @@ -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()) { diff --git a/gradle.properties b/gradle.properties index e86424f0..8b1a2183 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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