1
0
mirror of https://github.com/PurpleI2P/i2pd-android.git synced 2025-01-10 14:57:55 +00:00

fix assets unpack when not required

Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
R4SAS 2022-04-06 22:24:42 +03:00
parent 67fb27a6ce
commit f363c10040
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2

View File

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