Add logs for index item update

This commit is contained in:
Vitaliy 2020-12-28 13:27:16 +02:00
parent 4c546e3811
commit 777d93f696

View file

@ -8,9 +8,9 @@ import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.map.OsmandRegions; import net.osmand.map.OsmandRegions;
import net.osmand.map.WorldRegion; import net.osmand.map.WorldRegion;
import net.osmand.plus.CustomRegion;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.CustomRegion;
import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem; import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem;
import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -21,6 +21,7 @@ import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -177,6 +178,8 @@ public class DownloadResources extends DownloadResourceGroup {
} }
} }
if (date != null && !date.equals(indexActivatedDate) && !date.equals(indexFilesDate)) { if (date != null && !date.equals(indexActivatedDate) && !date.equals(indexFilesDate)) {
long oldItemSize = 0;
long itemSize = item.getContentSize();
if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra) if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra)
|| item.getType() == DownloadActivityType.ROADS_FILE || item.getType() == DownloadActivityType.ROADS_FILE
|| item.getType() == DownloadActivityType.WIKIPEDIA_FILE || item.getType() == DownloadActivityType.WIKIPEDIA_FILE
@ -185,15 +188,12 @@ public class DownloadResources extends DownloadResourceGroup {
outdated = true; outdated = true;
} else if (item.getType() == DownloadActivityType.WIKIVOYAGE_FILE } else if (item.getType() == DownloadActivityType.WIKIVOYAGE_FILE
|| item.getType() == DownloadActivityType.TRAVEL_FILE) { || item.getType() == DownloadActivityType.TRAVEL_FILE) {
long itemSize = item.getContentSize(); oldItemSize = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR +
long oldItemSize = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR +
item.getTargetFileName()).length(); item.getTargetFileName()).length();
if (itemSize != oldItemSize) { if (itemSize != oldItemSize) {
outdated = true; outdated = true;
} }
} else { } else {
long itemSize = item.getContentSize();
long oldItemSize = 0;
if (parsed && item.getTimestamp() > item.getLocalTimestamp()) { if (parsed && item.getTimestamp() > item.getLocalTimestamp()) {
outdated = true; outdated = true;
} else if (item.getType() == DownloadActivityType.VOICE_FILE) { } else if (item.getType() == DownloadActivityType.VOICE_FILE) {
@ -223,12 +223,23 @@ public class DownloadResources extends DownloadResourceGroup {
outdated = true; outdated = true;
} }
} }
if (outdated) {
logItemUpdateInfo(item, format, itemSize, oldItemSize);
}
} }
item.setOutdated(outdated); item.setOutdated(outdated);
return outdated; return outdated;
} }
private void logItemUpdateInfo(IndexItem item, DateFormat format, long itemSize, long oldItemSize) {
String date = item.getDate(format);
String sfName = item.getTargetFileName();
String indexActivatedDate = indexActivatedFileNames.get(sfName);
String indexFilesDate = indexFileNames.get(sfName);
LOG.info("timestamp " + item.timestamp + " localTimestamp " + item.localTimestamp + " date " + date
+ " indexActivatedDate " + indexActivatedDate + " indexFilesDate " + indexFilesDate
+ " itemSize " + itemSize + " oldItemSize " + oldItemSize);
}
protected void updateFilesToUpdate() { protected void updateFilesToUpdate() {
initAlreadyLoadedFiles(); initAlreadyLoadedFiles();