Remove duplicated map

This commit is contained in:
Victor Shcherb 2012-05-26 19:11:12 +02:00
parent e288f954bc
commit c9a0ecd240
2 changed files with 15 additions and 7 deletions

View file

@ -242,24 +242,23 @@ public class DownloadOsmandIndexesHelper {
String toCheckPostfix = null;
boolean unzipDir = false;
boolean preventMediaIndexing = false;
File externalStorageDirectory = ((OsmandApplication) ctx.getApplicationContext()).getSettings().getExternalStorageDirectory();
OsmandSettings settings = ((OsmandApplication) ctx.getApplicationContext()).getSettings();
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;
toCheckPostfix = BINARY_MAP_INDEX_EXT;
} 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;
toCheckPostfix = BINARY_MAP_INDEX_EXT;
} 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;
toCheckPostfix = ""; //$NON-NLS-1$
unzipDir = true;
preventMediaIndexing = true;
} 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;
toCheckPostfix = ""; //$NON-NLS-1$
unzipDir = true;
@ -300,6 +299,10 @@ public class DownloadOsmandIndexesHelper {
entry.parts = Integer.parseInt(item.getParts());
}
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;
}

View file

@ -24,6 +24,7 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import net.osmand.Algoritms;
import net.osmand.IProgress;
import net.osmand.access.AccessibleToast;
import net.osmand.data.IndexConstants;
@ -627,6 +628,9 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
if (result) {
entriesToDownload.remove(filename);
downloads.set(downloads.get() + 1);
if(entry.existingBackupFile != null) {
Algoritms.removeAllFiles(entry.existingBackupFile);
}
publishProgress(entry);
}
}
@ -672,6 +676,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
public double sizeMB;
public String baseName;
public int parts;
public File existingBackupFile;
public boolean downloadFile(DownloadFileHelper downloadFileHelper, String filename, List<File> filesToReindex,
IProgress progress, String indexOfAllFiles,