Update CachedOsmandIndexes after map download
This commit is contained in:
parent
f27c397835
commit
37bfc759b1
3 changed files with 15 additions and 11 deletions
|
@ -1,11 +1,5 @@
|
|||
package net.osmand.binary;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion;
|
||||
import net.osmand.binary.BinaryMapAddressReaderAdapter.CitiesBlock;
|
||||
|
@ -29,6 +23,12 @@ import net.osmand.binary.OsmandIndex.TransportPart;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
public class CachedOsmandIndexes {
|
||||
|
||||
private OsmAndStoredIndex storedIndex;
|
||||
|
@ -174,10 +174,10 @@ public class CachedOsmandIndexes {
|
|||
routing.addSubregions(rpart);
|
||||
}
|
||||
|
||||
public BinaryMapIndexReader getReader(File f) throws IOException {
|
||||
public BinaryMapIndexReader getReader(File f, boolean useStoredIndex) throws IOException {
|
||||
RandomAccessFile mf = new RandomAccessFile(f.getPath(), "r");
|
||||
FileIndex found = null;
|
||||
if (storedIndex != null) {
|
||||
if (storedIndex != null && useStoredIndex) {
|
||||
for (int i = 0; i < storedIndex.getFileIndexCount(); i++) {
|
||||
FileIndex fi = storedIndex.getFileIndex(i);
|
||||
if (f.length() == fi.getSize() && f.getName().equals(fi.getFileName())) {
|
||||
|
|
|
@ -576,7 +576,7 @@ public class DownloadIndexesThread {
|
|||
manager.indexVoiceFiles(this);
|
||||
manager.indexFontFiles(this);
|
||||
if (vectorMapsToReindex) {
|
||||
warnings = manager.indexingMaps(this);
|
||||
warnings = manager.indexingMaps(this, filesToReindex);
|
||||
}
|
||||
List<String> wns = manager.indexAdditionalMaps(this);
|
||||
if (wns != null) {
|
||||
|
|
|
@ -621,7 +621,11 @@ public class ResourceManager {
|
|||
}
|
||||
}
|
||||
|
||||
public List<String> indexingMaps(final IProgress progress) {
|
||||
public List<String> indexingMaps(IProgress progress) {
|
||||
return indexingMaps(progress, Collections.<File>emptyList());
|
||||
}
|
||||
|
||||
public List<String> indexingMaps(final IProgress progress, List<File> filesToReindex) {
|
||||
long val = System.currentTimeMillis();
|
||||
ArrayList<File> files = new ArrayList<File>();
|
||||
File appPath = context.getAppPath(null);
|
||||
|
@ -688,7 +692,7 @@ public class ResourceManager {
|
|||
try {
|
||||
BinaryMapIndexReader mapReader = null;
|
||||
try {
|
||||
mapReader = cachedOsmandIndexes.getReader(f);
|
||||
mapReader = cachedOsmandIndexes.getReader(f, !filesToReindex.contains(f));
|
||||
if (mapReader.getVersion() != IndexConstants.BINARY_MAP_VERSION) {
|
||||
mapReader = null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue