private void putDownloadables(List<? extends Downloadable> downloadables) { for (Downloadable downloadable : downloadables) { downloadableMap.put(downloadable.getUri(), downloadable); for (Fragment<Downloadable> fragment : downloadable.getFragments()) fragmentMap.put(fragment.getKey(), fragment); } }
private Download download(Downloadable downloadable) { List<FileAndChecksum> fragments = new ArrayList<>(); for (Fragment otherFragments : downloadable.getFragments()) { String key = otherFragments.getKey(); // ignore fragment keys without extension which are reported by old RouteConverter releases if (key.endsWith(DOT_HGT)) fragments.add(new FileAndChecksum(createFile(key), otherFragments.getLatestChecksum())); } String uri = downloadable.getUri(); String url = getBaseUrl() + uri; return downloadManager.queueForDownload(getName() + " Elevation Tile: " + uri, url, Action.valueOf(dataSource.getAction()), new FileAndChecksum(getDirectory(), downloadable.getLatestChecksum()), fragments); }
public Download queueForDownload(DataSource dataSource, Downloadable downloadable) { Action action = Action.valueOf(dataSource.getAction()); File directory = getApplicationDirectory(dataSource.getDirectory()); File target = new File(directory, downloadable.getUri()); if (action.equals(Extract) || action.equals(Flatten)) target = ensureDirectory(target.getParentFile()); return downloadManager.queueForDownload(dataSource.getName() + ": " + downloadable.getUri(), dataSource.getBaseUrl() + downloadable.getUri(), action, new FileAndChecksum(target, downloadable.getLatestChecksum()), asFragments(target, downloadable.getFragments(), false)); }
private void addOrUpdateInQueue(DataSource dataSource, Downloadable downloadable) { Action action = Action.valueOf(dataSource.getAction()); File directory = getApplicationDirectory(dataSource.getDirectory()); File target = directory; // Flatten if (action.equals(Copy)) target = new File(directory, downloadable.getUri()); else if (action.equals(Extract)) target = target.getParentFile(); downloadManager.addOrUpdateInQueue(dataSource.getName() + ": " + downloadable.getUri(), dataSource.getBaseUrl() + downloadable.getUri(), action, new FileAndChecksum(target, downloadable.getLatestChecksum()), asFragments(directory, downloadable.getFragments(), action.equals(Extract))); }