Check ProfileFile existence first
Avoid java.nio.file.NoSuchFileException when readAttributes.
This commit is contained in:
parent
87a765d65c
commit
c3ee8bec23
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue