From 6d987d083ea499f3698ea3324feed19b4de3909d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 16 Oct 2025 23:56:31 +0500 Subject: [PATCH] android: delete .nomedia if it's a directory --- .../app/src/main/java/su/xash/engine/util/Nomedia.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/android/app/src/main/java/su/xash/engine/util/Nomedia.kt b/android/app/src/main/java/su/xash/engine/util/Nomedia.kt index cdb24db2..80cb003c 100644 --- a/android/app/src/main/java/su/xash/engine/util/Nomedia.kt +++ b/android/app/src/main/java/su/xash/engine/util/Nomedia.kt @@ -30,6 +30,16 @@ object Nomedia { val nomediaFile = File(directory, ".nomedia") + // if the .nomedia is directory, remove it + if (nomediaFile.isDirectory) { + // it should be empty to be deleted, but that's good + // because this way we're not deleting something important + // (who would stash important files in .nomedia directory though...) + if (!nomediaFile.delete()) { + return false + } + } + // it returns false if file already exists, which is fine for us nomediaFile.createNewFile()