Skip local directories with .notamanga file
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.koitharu.kotatsu.local.data
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.core.net.toFile
|
||||
import androidx.core.net.toUri
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -17,7 +16,6 @@ import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.core.util.AlphanumComparator
|
||||
import org.koitharu.kotatsu.core.util.ext.deleteAwait
|
||||
import org.koitharu.kotatsu.core.util.ext.isWriteable
|
||||
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
||||
import org.koitharu.kotatsu.core.util.ext.takeIfWriteable
|
||||
import org.koitharu.kotatsu.core.util.ext.withChildren
|
||||
@@ -45,6 +43,7 @@ import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
private const val MAX_PARALLELISM = 4
|
||||
private const val FILENAME_SKIP = ".notamanga"
|
||||
|
||||
@Singleton
|
||||
class LocalMangaRepository @Inject constructor(
|
||||
@@ -140,7 +139,7 @@ class LocalMangaRepository @Inject constructor(
|
||||
}
|
||||
|
||||
suspend fun delete(manga: Manga): Boolean {
|
||||
val file = Uri.parse(manga.url).toFile()
|
||||
val file = manga.url.toUri().toFile()
|
||||
val result = file.deleteAwait()
|
||||
if (result) {
|
||||
localMangaIndex.delete(manga.id)
|
||||
@@ -256,8 +255,10 @@ class LocalMangaRepository @Inject constructor(
|
||||
private suspend fun getAllFiles() = storageManager.getReadableDirs()
|
||||
.asSequence()
|
||||
.flatMap { dir ->
|
||||
dir.withChildren { children -> children.filterNot { it.isHidden }.toList() }
|
||||
dir.withChildren { children -> children.filterNot { it.isHidden || it.shouldSkip() }.toList() }
|
||||
}
|
||||
|
||||
private fun Collection<LocalManga>.unwrap(): List<Manga> = map { it.manga }
|
||||
|
||||
private fun File.shouldSkip(): Boolean = isDirectory && File(this, FILENAME_SKIP).exists()
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ material = "1.13.0-alpha12"
|
||||
moshi = "1.15.2"
|
||||
okhttp = "4.12.0"
|
||||
okio = "3.10.2"
|
||||
parsers = "dbb04d2051"
|
||||
parsers = "8bb0c4f4f1"
|
||||
preference = "1.2.1"
|
||||
recyclerview = "1.4.0"
|
||||
room = "2.6.1"
|
||||
|
||||
Reference in New Issue
Block a user