From 19e69a70f3db2fac3ea1861ac71433125b33c3ec Mon Sep 17 00:00:00 2001 From: Zahnstocher Date: Sun, 29 Oct 2017 21:14:49 +0100 Subject: [PATCH] Storage leak download fix #4656 --- OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java index 7f40bd6d4a..dd77eea2be 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java @@ -213,7 +213,11 @@ public class DownloadFileHelper { } unzipFile(de, progress, downloadInputStreams); if(!de.targetFile.getAbsolutePath().equals(de.fileToDownload.getAbsolutePath())){ - Algorithms.removeAllFiles(de.targetFile); + boolean successfull = Algorithms.removeAllFiles(de.targetFile); + if (successfull) { + ctx.getResourceManager().closeFile(de.targetFile.getName()); + } + boolean renamed = de.fileToDownload.renameTo(de.targetFile); if(!renamed) { showWarningCallback.showWarning(ctx.getString(R.string.shared_string_io_error) + ": old file can't be deleted");