From c3ee8bec23e96a7df57605fcb05a81b2daef872a Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Thu, 20 Jul 2023 12:21:42 +0200 Subject: [PATCH] Check ProfileFile existence first Avoid java.nio.file.NoSuchFileException when readAttributes. --- .../java/org/lsposed/lspatch/loader/LSPApplication.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patch-loader/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java b/patch-loader/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java index 3180350..ced217f 100644 --- a/patch-loader/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java +++ b/patch-loader/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java @@ -208,6 +208,10 @@ public class LSPApplication { File curProfileFile = new File(profileDir, splitName == null ? "primary.prof" : splitName + ".split.prof").getAbsoluteFile(); Log.d(TAG, "Processing " + curProfileFile.getAbsolutePath()); try { + if (!curProfileFile.exists()) { + Files.createFile(curProfileFile.toPath(), attrs); + continue; + } if (!curProfileFile.canWrite() && Files.size(curProfileFile.toPath()) == 0) { Log.d(TAG, "Skip profile " + curProfileFile.getAbsolutePath()); continue; @@ -219,8 +223,6 @@ public class LSPApplication { Log.e(TAG, "Failed to delete and clear profile file " + curProfileFile.getAbsolutePath(), e); } Os.chmod(curProfileFile.getAbsolutePath(), 00400); - } else { - Files.createFile(curProfileFile.toPath(), attrs); } } catch (Throwable e) { Log.e(TAG, "Failed to disable profile file " + curProfileFile.getAbsolutePath(), e);