diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java index d13bb63cd1..56b5731577 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java @@ -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())) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 3355d67a32..9d47f57762 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -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 wns = manager.indexAdditionalMaps(this); if (wns != null) { diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index ffd8bb4e83..db1c3c96d6 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -621,7 +621,11 @@ public class ResourceManager { } } - public List indexingMaps(final IProgress progress) { + public List indexingMaps(IProgress progress) { + return indexingMaps(progress, Collections.emptyList()); + } + + public List indexingMaps(final IProgress progress, List filesToReindex) { long val = System.currentTimeMillis(); ArrayList files = new ArrayList(); 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; }