Remove duplicated map
This commit is contained in:
parent
e288f954bc
commit
c9a0ecd240
2 changed files with 15 additions and 7 deletions
|
@ -242,24 +242,23 @@ public class DownloadOsmandIndexesHelper {
|
||||||
String toCheckPostfix = null;
|
String toCheckPostfix = null;
|
||||||
boolean unzipDir = false;
|
boolean unzipDir = false;
|
||||||
boolean preventMediaIndexing = false;
|
boolean preventMediaIndexing = false;
|
||||||
|
OsmandSettings settings = ((OsmandApplication) ctx.getApplicationContext()).getSettings();
|
||||||
File externalStorageDirectory = ((OsmandApplication) ctx.getApplicationContext()).getSettings().getExternalStorageDirectory();
|
|
||||||
if(fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)){
|
if(fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)){
|
||||||
parent = new File(externalStorageDirectory, ResourceManager.APP_DIR);
|
parent = settings.extendOsmandPath(ResourceManager.APP_DIR);
|
||||||
toSavePostfix = BINARY_MAP_INDEX_EXT;
|
toSavePostfix = BINARY_MAP_INDEX_EXT;
|
||||||
toCheckPostfix = BINARY_MAP_INDEX_EXT;
|
toCheckPostfix = BINARY_MAP_INDEX_EXT;
|
||||||
} else if(fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP)){
|
} else if(fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP)){
|
||||||
parent = new File(externalStorageDirectory, ResourceManager.APP_DIR);
|
parent = settings.extendOsmandPath(ResourceManager.APP_DIR);
|
||||||
toSavePostfix = BINARY_MAP_INDEX_EXT_ZIP;
|
toSavePostfix = BINARY_MAP_INDEX_EXT_ZIP;
|
||||||
toCheckPostfix = BINARY_MAP_INDEX_EXT;
|
toCheckPostfix = BINARY_MAP_INDEX_EXT;
|
||||||
} else if(fileName.endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)){
|
} else if(fileName.endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)){
|
||||||
parent = new File(externalStorageDirectory, ResourceManager.VOICE_PATH);
|
parent = settings.extendOsmandPath(ResourceManager.VOICE_PATH);
|
||||||
toSavePostfix = VOICE_INDEX_EXT_ZIP;
|
toSavePostfix = VOICE_INDEX_EXT_ZIP;
|
||||||
toCheckPostfix = ""; //$NON-NLS-1$
|
toCheckPostfix = ""; //$NON-NLS-1$
|
||||||
unzipDir = true;
|
unzipDir = true;
|
||||||
preventMediaIndexing = true;
|
preventMediaIndexing = true;
|
||||||
} else if(fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_ZIP)){
|
} else if(fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_ZIP)){
|
||||||
parent = new File(externalStorageDirectory, ResourceManager.VOICE_PATH);
|
parent = settings.extendOsmandPath(ResourceManager.VOICE_PATH);
|
||||||
toSavePostfix = TTSVOICE_INDEX_EXT_ZIP;
|
toSavePostfix = TTSVOICE_INDEX_EXT_ZIP;
|
||||||
toCheckPostfix = ""; //$NON-NLS-1$
|
toCheckPostfix = ""; //$NON-NLS-1$
|
||||||
unzipDir = true;
|
unzipDir = true;
|
||||||
|
@ -296,10 +295,14 @@ public class DownloadOsmandIndexesHelper {
|
||||||
} catch (NumberFormatException e1) {
|
} catch (NumberFormatException e1) {
|
||||||
}
|
}
|
||||||
entry.parts = 1;
|
entry.parts = 1;
|
||||||
if(item.getParts() != null){
|
if (item.getParts() != null) {
|
||||||
entry.parts = Integer.parseInt(item.getParts());
|
entry.parts = Integer.parseInt(item.getParts());
|
||||||
}
|
}
|
||||||
entry.fileToUnzip = new File(parent, entry.baseName + toCheckPostfix);
|
entry.fileToUnzip = new File(parent, entry.baseName + toCheckPostfix);
|
||||||
|
File backup = settings.extendOsmandPath(ResourceManager.BACKUP_PATH + entry.fileToUnzip.getName());
|
||||||
|
if (backup.exists()) {
|
||||||
|
entry.existingBackupFile = backup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import net.osmand.Algoritms;
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.IndexConstants;
|
import net.osmand.data.IndexConstants;
|
||||||
|
@ -627,6 +628,9 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
if (result) {
|
if (result) {
|
||||||
entriesToDownload.remove(filename);
|
entriesToDownload.remove(filename);
|
||||||
downloads.set(downloads.get() + 1);
|
downloads.set(downloads.get() + 1);
|
||||||
|
if(entry.existingBackupFile != null) {
|
||||||
|
Algoritms.removeAllFiles(entry.existingBackupFile);
|
||||||
|
}
|
||||||
publishProgress(entry);
|
publishProgress(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,6 +676,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
public double sizeMB;
|
public double sizeMB;
|
||||||
public String baseName;
|
public String baseName;
|
||||||
public int parts;
|
public int parts;
|
||||||
|
public File existingBackupFile;
|
||||||
|
|
||||||
public boolean downloadFile(DownloadFileHelper downloadFileHelper, String filename, List<File> filesToReindex,
|
public boolean downloadFile(DownloadFileHelper downloadFileHelper, String filename, List<File> filesToReindex,
|
||||||
IProgress progress, String indexOfAllFiles,
|
IProgress progress, String indexOfAllFiles,
|
||||||
|
|
Loading…
Reference in a new issue