diff --git a/OsmAnd/src/net/osmand/plus/settings/datastorage/task/RefreshUsedMemoryTask.java b/OsmAnd/src/net/osmand/plus/settings/datastorage/task/RefreshUsedMemoryTask.java index 6f45676888..0af4cf34cb 100644 --- a/OsmAnd/src/net/osmand/plus/settings/datastorage/task/RefreshUsedMemoryTask.java +++ b/OsmAnd/src/net/osmand/plus/settings/datastorage/task/RefreshUsedMemoryTask.java @@ -99,16 +99,19 @@ public class RefreshUsedMemoryTask extends AsyncTask { for (MemoryItem memoryItem : items) { DirectoryItem[] targetDirectories = memoryItem.getDirectories(); if (targetDirectories != null) { - for (DirectoryItem targetDirectory : targetDirectories) { - String allowedDirPath = targetDirectory.getAbsolutePath(); - if (objectEquals(directoryPath, allowedDirPath) - || (directoryPath.startsWith(allowedDirPath))) { - if (targetDirectory.shouldProcessInternalDirectories()) { - calculateMultiTypes(directory, items); - return; - } else if (!targetDirectory.shouldAddUnmatchedToOtherMemory()) { - return; - } + for (DirectoryItem dir : targetDirectories) { + String allowedDirPath = dir.getAbsolutePath(); + boolean isPerfectlyMatch = objectEquals(directoryPath, allowedDirPath); + boolean isParentDirectory = !isPerfectlyMatch && (directoryPath.startsWith(allowedDirPath)); + boolean isMatchDirectory = isPerfectlyMatch || isParentDirectory; + if (isPerfectlyMatch) { + calculateMultiTypes(directory, items); + return; + } else if (isParentDirectory && dir.shouldProcessInternalDirectories()) { + calculateMultiTypes(directory, items); + return; + } else if (isMatchDirectory && !dir.shouldAddUnmatchedToOtherMemory()) { + return; } } } @@ -122,7 +125,7 @@ public class RefreshUsedMemoryTask extends AsyncTask { @NonNull MemoryItem... items) { for (MemoryItem item : items) { DirectoryItem[] targetDirectories = item.getDirectories(); - if (targetDirectories == null) continue; + if (targetDirectories == null) return; String rootDirPath = rootDir.getAbsolutePath(); for (DirectoryItem targetDirectory : targetDirectories) {