From a7af2a3cf0586eb067c29a3758e8576dd46154e1 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 16 Oct 2020 01:16:42 +0300 Subject: [PATCH] Fix subfolders for files import --- .../plus/settings/backend/backup/FileSettingsItem.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java index c8d2838ae9..357c0aadbf 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java @@ -115,7 +115,14 @@ public class FileSettingsItem extends StreamSettingsItem { } else if (subtype == FileSubtype.UNKNOWN || subtype == null) { throw new IllegalArgumentException("Unknown file subtype: " + getFileName()); } else { - this.file = new File(app.getAppPath(subtype.subtypeFolder), name); + String subtypeFolder = subtype.subtypeFolder; + int nameIndex = fileName.indexOf(name); + int folderIndex = fileName.indexOf(subtype.subtypeFolder); + if (nameIndex != -1 && folderIndex != -1) { + String subfolderPath = fileName.substring(folderIndex + subtype.subtypeFolder.length(), nameIndex); + subtypeFolder = subtypeFolder + subfolderPath; + } + this.file = new File(app.getAppPath(subtypeFolder), name); } }