From 6c7fdd1b72425bebda5459b15eb2d566d289de8f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 18 Jan 2012 23:25:22 +0100 Subject: [PATCH] Add file indexing differently --- .../plus/activities/DownloadFileHelper.java | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java b/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java index 282d36043d..611136e6f4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadFileHelper.java @@ -7,7 +7,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; -import java.util.ArrayList; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -24,7 +23,6 @@ import net.osmand.LogUtil; import net.osmand.Version; import net.osmand.data.IndexConstants; import net.osmand.plus.R; -import net.osmand.plus.ResourceManager; public class DownloadFileHelper { @@ -152,11 +150,8 @@ public class DownloadFileHelper { out = null; } - File toIndex = fileToDownload; if (fileToDownload.getName().endsWith(".zip")) { //$NON-NLS-1$ - if (!unzipToDir) { - toIndex = fileToUnZip; - } else { + if (unzipToDir) { fileToUnZip.mkdirs(); } ZipInputStream zipIn = new ZipInputStream(new FileInputStream(fileToDownload)); @@ -171,7 +166,7 @@ public class DownloadFileHelper { File fs; if (!unzipToDir) { if (first) { - fs = toIndex; + fs = fileToUnZip; first = false; } else { String name = entry.getName(); @@ -185,7 +180,6 @@ public class DownloadFileHelper { } } fs = new File(fileToUnZip.getParent(), name); - toIndex = fs; } } else { fs = new File(fileToUnZip, entry.getName()); @@ -202,23 +196,13 @@ public class DownloadFileHelper { if(dateModified != null){ fs.setLastModified(dateModified); } + toReIndex.add(fs); } zipIn.close(); fileToDownload.delete(); // zip is no needed more } - ArrayList warnings = new ArrayList(); - ResourceManager manager = ((OsmandApplication) ctx.getApplicationContext()).getResourceManager(); - if(dateModified != null){ - toIndex.setLastModified(dateModified); - manager.updateIndexLastDateModified(toIndex); - } - toReIndex.add(toIndex); - if (warnings.isEmpty()) { - showWarningCallback.showWarning(ctx.getString(R.string.download_index_success)); - } else { - showWarningCallback.showWarning(warnings.get(0)); - } + showWarningCallback.showWarning(ctx.getString(R.string.download_index_success)); return true; } catch (IOException e) { log.error("Exception ocurred", e); //$NON-NLS-1$