Browse Source

fix assets unpack when not required

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/44/head
R4SAS 3 years ago
parent
commit
f363c10040
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 79
      app/src/main/java/org/purplei2p/i2pd/DaemonWrapper.java

79
app/src/main/java/org/purplei2p/i2pd/DaemonWrapper.java

@ -203,58 +203,51 @@ public class DaemonWrapper { @@ -203,58 +203,51 @@ public class DaemonWrapper {
}
private void processAssets() {
if (!assetsCopied) {
try {
assetsCopied = true;
File holderFile = new File(i2pdpath, "assets.ready");
String versionName = BuildConfig.VERSION_NAME; // here will be app version, like 2.XX.XX
StringBuilder text = new StringBuilder();
Log.d(TAG, "checking assets");
if (holderFile.exists()) {
try { // if holder file exists, read assets version string
FileReader fileReader = new FileReader(holderFile);
File holderFile = new File(i2pdpath, "assets.ready");
String versionName = BuildConfig.VERSION_NAME; // here will be app version, like 2.XX.XX
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(fileReader);
if (holderFile.exists()) {
try { // if holder file exists, read assets version string
FileReader fileReader = new FileReader(holderFile);
try {
String line;
while ((line = br.readLine()) != null) {
text.append(line);
}
}finally {
try {
BufferedReader br = new BufferedReader(fileReader);
try {
String line;
while ((line = br.readLine()) != null) {
text.append(line);
}
}finally {
try {
br.close();
} catch (IOException e) {
Log.e(TAG, "", e);
}
}
} finally {
try {
fileReader.close();
} catch (IOException e) {
Log.e(TAG, "", e);
}
br.close();
} catch (IOException e) {
Log.e(TAG, "", e);
}
}
} finally {
try {
fileReader.close();
} catch (IOException e) {
Log.e(TAG, "", e);
}
}
} catch (IOException e) {
Log.e(TAG, "", e);
}
}
// if version differs from current app version or null, try to delete certificates folder
if (!text.toString().contains(versionName))
try {
boolean deleteResult = holderFile.delete();
if (!deleteResult)
Log.e(TAG, "holderFile.delete() returned " + deleteResult + ", absolute path='" + holderFile.getAbsolutePath() + "'");
File certPath = new File(i2pdpath, "certificates");
deleteRecursive(certPath);
}
catch (Throwable tr) {
Log.e(TAG, "", tr);
}
// if version differs from current app version or null, try to delete certificates folder
if (!text.toString().contains(versionName)) {
try {
boolean deleteResult = holderFile.delete();
if (!deleteResult)
Log.e(TAG, "holderFile.delete() returned " + deleteResult + ", absolute path='" + holderFile.getAbsolutePath() + "'");
File certPath = new File(i2pdpath, "certificates");
deleteRecursive(certPath);
// copy assets. If processed file exists, it won't be overwritten
copyAsset("addressbook");
@ -309,7 +302,7 @@ public class DaemonWrapper { @@ -309,7 +302,7 @@ public class DaemonWrapper {
// Make the directory.
File dir = new File(i2pdpath, path);
boolean result = dir.mkdirs();
Log.d(TAG, "dir.mkdirs() returned " + result);
Log.d(TAG, "dir.mkdirs() returned " + result + " for " + dir);
// Recurse on the contents.
for (String entry : contents) {

Loading…
Cancel
Save