Fix issue
This commit is contained in:
parent
39051c7004
commit
81d026aa25
3 changed files with 38 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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<File> collectChangesFiles(File dir, String ext, List<File> files) {
|
||||
if (dir.exists() && dir.canRead()) {
|
||||
File[] lf = dir.listFiles();
|
||||
if (lf == null || lf.length == 0) {
|
||||
return files;
|
||||
}
|
||||
Set<String> existingFiles = new HashSet<String>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<File> collectFiles(File dir, String ext, List<File> 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<File> files, File roadsPath) {
|
||||
Iterator<File> 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());
|
||||
|
|
Loading…
Reference in a new issue