Merge pull request #913 from Bars107/configcopy
Fixed issue with _config.p not copying from assets
This commit is contained in:
commit
44fe08a27e
4 changed files with 23 additions and 24 deletions
|
@ -217,6 +217,9 @@ public class DownloadFileHelper {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (de.type == DownloadActivityType.VOICE_FILE){
|
||||
copyVoiceConfig(de);
|
||||
}
|
||||
toReIndex.add(de.targetFile);
|
||||
showWarningCallback.showWarning(ctx.getString(R.string.download_index_success));
|
||||
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 {
|
||||
CountingMultiInputStream fin = new CountingMultiInputStream(is);
|
||||
int len = (int) fin.available();
|
||||
|
|
|
@ -328,8 +328,8 @@ public class DownloadIndexesThread {
|
|||
boolean res = false;
|
||||
if (de.isAsset) {
|
||||
try {
|
||||
if (uiActivity != null) {
|
||||
ResourceManager.copyAssets(uiActivity.getAssets(), de.assetName, de.targetFile);
|
||||
if (ctx != null) {
|
||||
ResourceManager.copyAssets(ctx.getAssets(), de.assetName, de.targetFile);
|
||||
boolean changedDate = de.targetFile.setLastModified(de.dateModified);
|
||||
if(!changedDate) {
|
||||
log.error("Set last timestamp is not supported");
|
||||
|
@ -550,7 +550,7 @@ public class DownloadIndexesThread {
|
|||
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
|
||||
for (IndexItem item : itemsToUpdate) {
|
||||
String sfName = item.getTargetFileName();
|
||||
java.text.DateFormat format = uiActivity.getMyApplication().getResourceManager().getDateFormat();
|
||||
java.text.DateFormat format = app.getResourceManager().getDateFormat();
|
||||
String date = item.getDate(format);
|
||||
String indexactivateddate = indexActivatedFileNames.get(sfName);
|
||||
String indexfilesdate = indexFileNames.get(sfName);
|
||||
|
|
|
@ -85,19 +85,6 @@ public class DownloadOsmandIndexesHelper {
|
|||
File destFile = new File(voicePath, voice + File.separatorChar + "_ttsconfig.p");
|
||||
result.add(new AssetIndexItem(voice +ext, "voice", date, dateModified,
|
||||
"0.1", 1024*100, key, destFile.getPath(), DownloadActivityType.VOICE_FILE));
|
||||
} else if (target.endsWith("/_config.p") && target.startsWith("voice/")) {
|
||||
String voice = target.substring("voice/".length(), target.length() - "/_config.p".length());
|
||||
IndexItem item = result.getIndexFilesByName(key);
|
||||
if (item != null) {
|
||||
File destFile = new File(voicePath, voice + File.separatorChar + "_config.p");
|
||||
// always use bundled config
|
||||
// if (item.getTimestamp() > dateModified) {
|
||||
// continue;
|
||||
// }
|
||||
item.timestamp = dateModified;
|
||||
item.attachedItem = new AssetIndexItem(voice +extvoice, "voice", date, dateModified, "0.1", 1024*100, key, destFile.getPath(),
|
||||
DownloadActivityType.VOICE_FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.sort();
|
||||
|
|
|
@ -27,7 +27,6 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
long timestamp;
|
||||
long contentSize;
|
||||
long containerSize;
|
||||
IndexItem attachedItem;
|
||||
DownloadActivityType type;
|
||||
|
||||
|
||||
|
@ -99,13 +98,6 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
if (backup.exists()) {
|
||||
entry.existingBackupFile = backup;
|
||||
}
|
||||
if (attachedItem != null) {
|
||||
ArrayList<DownloadEntry> sz = new ArrayList<DownloadEntry>();
|
||||
attachedItem.createDownloadEntry(ctx, type, sz);
|
||||
if(sz.size() > 0) {
|
||||
entry.attachedEntry = sz.get(0);
|
||||
}
|
||||
}
|
||||
downloadEntries.add(entry);
|
||||
}
|
||||
return downloadEntries;
|
||||
|
|
Loading…
Reference in a new issue