android - dont rewrite files from assets if they exist

This commit is contained in:
r4sas 2018-08-15 01:49:10 +03:00
parent f1fb42460a
commit d009a29426

View File

@ -36,7 +36,6 @@ public class I2PDActivity extends Activity {
private final DaemonSingleton.StateUpdateListener daemonStateUpdatedListener =
new DaemonSingleton.StateUpdateListener() {
@Override
public void daemonStateUpdate()
{
@ -48,7 +47,7 @@ public class I2PDActivity extends Activity {
assetsCopied = true;
copyAsset("certificates");
copyAsset("i2pd.conf");
copyAsset("subsciptions.txt");
copyAsset("subscriptions.txt");
copyAsset("tunnels.conf");
}
}
@ -74,7 +73,7 @@ public class I2PDActivity extends Activity {
(DaemonSingleton.State.startFailed.equals(state)?": "+daemon.getDaemonStartResult():"")+
(DaemonSingleton.State.gracefulShutdownInProgress.equals(state)?": "+formatGraceTimeRemaining()+" "+getText(R.string.remaining):"")
);
} catch (Throwable tr) {
} catch (Throwable tr) {
Log.e(TAG,"error ignored",tr);
}
}
@ -172,7 +171,6 @@ public class I2PDActivity extends Activity {
}
};
private static volatile boolean mIsBound;
private void doBindService() {
@ -340,7 +338,7 @@ public class I2PDActivity extends Activity {
for (String entry : contents) {
copyAsset(path + "/" + entry);
}
} catch (IOException e) {
} catch (IOException e) {
copyFileAsset(path);
}
}
@ -354,7 +352,7 @@ public class I2PDActivity extends Activity {
*/
private void copyFileAsset(String path) {
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/i2pd/", path);
try {
if(!file.exists()) try {
InputStream in = getAssets().open(path);
OutputStream out = new FileOutputStream(file);
byte[] buffer = new byte[1024];
@ -365,7 +363,7 @@ public class I2PDActivity extends Activity {
}
out.close();
in.close();
} catch (IOException e) {
} catch (IOException e) {
Log.e(TAG, "", e);
}
}