From ca8eaae1b8d2d581fc078cdb821ec984fd0f2945 Mon Sep 17 00:00:00 2001 From: 21561 <215613905@qq.com> Date: Sun, 23 Mar 2025 18:49:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=95=BF=E6=97=B6=E9=97=B4=E6=9C=AA=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=B8=85=E7=90=86=E8=BF=87jar=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=B0=86=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86(=E8=87=AA?= =?UTF-8?q?=E5=B8=A6md5=E9=99=A4=E5=A4=96);?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/github/catvod/crawler/JarLoader.java | 4 +++- app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java | 2 +- app/src/main/java/com/github/tvbox/osc/util/FileUtils.java | 7 +++++++ gradle.properties | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) 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