Fixed issue with _config.p not copying from assets

This commit is contained in:
Denis 2014-10-09 15:28:41 +03:00
parent fa0a23450b
commit 461bfe0282
2 changed files with 22 additions and 2 deletions

View file

@ -217,6 +217,9 @@ public class DownloadFileHelper {
return false; return false;
} }
} }
if (de.type == DownloadActivityType.VOICE_FILE){
copyVoiceConfig(de);
}
toReIndex.add(de.targetFile); toReIndex.add(de.targetFile);
showWarningCallback.showWarning(ctx.getString(R.string.download_index_success)); showWarningCallback.showWarning(ctx.getString(R.string.download_index_success));
return true; return true;
@ -229,6 +232,23 @@ public class DownloadFileHelper {
} }
} }
private void copyVoiceConfig(DownloadEntry de) {
File f = ctx.getAppPath("/voice/" + de.baseName + "/_config.p");
if (f.exists()) try {
InputStream is = ctx.getAssets().open("voice/" + de.baseName + "/config.p");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
FileOutputStream fos = new FileOutputStream(f);
fos.write(buffer);
fos.close();
} catch (Exception ex){
log.debug(ex.getMessage());
}
}
private void unzipFile(DownloadEntry de, IProgress progress, List<InputStream> is) throws IOException { private void unzipFile(DownloadEntry de, IProgress progress, List<InputStream> is) throws IOException {
CountingMultiInputStream fin = new CountingMultiInputStream(is); CountingMultiInputStream fin = new CountingMultiInputStream(is);
int len = (int) fin.available(); int len = (int) fin.available();

View file

@ -328,8 +328,8 @@ public class DownloadIndexesThread {
boolean res = false; boolean res = false;
if (de.isAsset) { if (de.isAsset) {
try { try {
if (uiActivity != null) { if (ctx != null) {
ResourceManager.copyAssets(uiActivity.getAssets(), de.assetName, de.targetFile); ResourceManager.copyAssets(ctx.getAssets(), de.assetName, de.targetFile);
boolean changedDate = de.targetFile.setLastModified(de.dateModified); boolean changedDate = de.targetFile.setLastModified(de.dateModified);
if(!changedDate) { if(!changedDate) {
log.error("Set last timestamp is not supported"); log.error("Set last timestamp is not supported");