diff --git a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java index 270c06a12f..549e5e1a26 100644 --- a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java @@ -404,6 +404,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { successfull = move(new File(info.getPathToData()), getFileToBackup(info)); if(successfull){ info.setBackupedData(true); + getMyApplication().getResourceManager().closeFile(info.getFileName()); } } total ++; @@ -439,7 +440,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { @Override protected void onPreExecute() { - getDownloadActivity().setProgressBarIndeterminateVisibility(true); + getDownloadActivity().setProgressBarIndeterminateVisibility(true); } @Override diff --git a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java index d2b461d3d0..079769c771 100644 --- a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java @@ -5,9 +5,11 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -31,6 +33,32 @@ public class IncrementalChangesManager { public IncrementalChangesManager(ResourceManager resourceManager) { this.resourceManager = resourceManager; } + + public List collectChangesFiles(File dir, String ext, List files) { + if (dir.exists() && dir.canRead()) { + File[] lf = dir.listFiles(); + if (lf == null || lf.length == 0) { + return files; + } + Set existingFiles = new HashSet(); + for (File f : files) { + existingFiles.add(Algorithms.getFileNameWithoutExtension(f)); + } + for (File f : lf) { + if (f.getName().endsWith(ext)) { + String index = Algorithms.getFileNameWithoutExtension(f); + if (index.length() >= 9 || index.charAt(index.length() - 9) != '_') { + String nm = index.substring(0, index.length() - 9); + if (existingFiles.contains(nm)) { + files.add(f); + } + } + + } + } + } + return files; + } public void indexMainMap(File f, long dateCreated) { String nm = Algorithms.getFileNameWithoutExtension(f).toLowerCase(); @@ -309,5 +337,5 @@ public class IncrementalChangesManager { return iul; } - + } diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index fa044782f4..fc65eeee8d 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -10,10 +10,12 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import net.osmand.AndroidUtils; @@ -575,8 +577,8 @@ public class ResourceManager { private List collectFiles(File dir, String ext, List files) { if(dir.exists() && dir.canRead()) { File[] lf = dir.listFiles(); - if(lf == null) { - lf = new File[0]; + if(lf == null || lf.length == 0) { + return files; } for (File f : lf) { if (f.getName().endsWith(ext)) { @@ -587,6 +589,8 @@ public class ResourceManager { return files; } + + private void renameRoadsFiles(ArrayList files, File roadsPath) { Iterator it = files.iterator(); while(it.hasNext()) { @@ -618,7 +622,7 @@ public class ResourceManager { } if(context.getSettings().BETA_TESTING_LIVE_UPDATES.get()) { - collectFiles(context.getAppPath(IndexConstants.LIVE_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); + changesManager.collectChangesFiles(context.getAppPath(IndexConstants.LIVE_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); } Collections.sort(files, Algorithms.getFileVersionComparator());