mirror of
https://github.com/PurpleI2P/i2pd-android.git
synced 2025-01-09 06:17:53 +00:00
fix assets unpack when not required
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
67fb27a6ce
commit
f363c10040
@ -203,58 +203,51 @@ public class DaemonWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processAssets() {
|
private void processAssets() {
|
||||||
if (!assetsCopied) {
|
File holderFile = new File(i2pdpath, "assets.ready");
|
||||||
try {
|
String versionName = BuildConfig.VERSION_NAME; // here will be app version, like 2.XX.XX
|
||||||
assetsCopied = true;
|
StringBuilder text = new StringBuilder();
|
||||||
|
Log.d(TAG, "checking assets");
|
||||||
|
|
||||||
File holderFile = new File(i2pdpath, "assets.ready");
|
if (holderFile.exists()) {
|
||||||
String versionName = BuildConfig.VERSION_NAME; // here will be app version, like 2.XX.XX
|
try { // if holder file exists, read assets version string
|
||||||
StringBuilder text = new StringBuilder();
|
FileReader fileReader = new FileReader(holderFile);
|
||||||
|
|
||||||
if (holderFile.exists()) {
|
try {
|
||||||
try { // if holder file exists, read assets version string
|
BufferedReader br = new BufferedReader(fileReader);
|
||||||
FileReader fileReader = new FileReader(holderFile);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedReader br = new BufferedReader(fileReader);
|
String line;
|
||||||
|
|
||||||
try {
|
while ((line = br.readLine()) != null) {
|
||||||
String line;
|
text.append(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
fileReader.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "", 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 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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user