diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java b/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java index 07754e57a..df4c8592b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java @@ -80,7 +80,8 @@ public boolean onTouch(View view, MotionEvent motionEvent) { // Move to /sdcard/Android/...... automatically if (Build.VERSION.SDK_INT >= 30) { ContextCompat.getMainExecutor(getContext()).execute(() -> { - if (!NekoConfig.cachePath.String().contains("/data/")) { + var directories = EnvUtil.getAvailableDirectories(); + if (!NekoConfig.cachePath.String().contains("/data/") && directories.length > 3) { NekoConfig.cachePath.setConfigString(EnvUtil.getAvailableDirectories()[2]); ImageLoader.getInstance().checkMediaPaths(); } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt index 447212be7..3925b45bd 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt @@ -51,16 +51,17 @@ object EnvUtil { // This is the only media path of NekoX, don't use other! @JvmStatic fun getTelegramPath(): File { + var defaultIndex = if (availableDirectories.size > 3) 2 else 0 if (NekoConfig.cachePath.String() == "") { // https://github.com/NekoX-Dev/NekoX/issues/284 - NekoConfig.cachePath.setConfigString(availableDirectories[2]); + NekoConfig.cachePath.setConfigString(availableDirectories[defaultIndex]); } var telegramPath = File(NekoConfig.cachePath.String()) if (telegramPath.isDirectory || telegramPath.mkdirs()) { return telegramPath } else { - NekoConfig.cachePath.setConfigString(availableDirectories[2]) + NekoConfig.cachePath.setConfigString(availableDirectories[defaultIndex]) } // fallback