Skip to content

Commit

Permalink
Always ignore saves & screenshots in fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
juraj-hrivnak committed Oct 8, 2024
1 parent a9ad32e commit bd17132
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ suspend fun deleteOldFiles(
)
}

@Suppress("ConvertCallChainIntoSequence")
val defaultIgnoredPaths = listOf("saves", "screenshots")

val channel = produce { ProjectType.entries
.filterNot { it == ProjectType.WORLD }
.mapNotNull { projectType ->
val prjTypeDir = Path(workingPath, projectType.getPathString(configFile))
if (prjTypeDir.notExists()) return@mapNotNull null
if (prjTypeDir.notExists() ||
defaultIgnoredPaths.any { it in prjTypeDir.pathString }) return@mapNotNull null

prjTypeDir
}
Expand Down Expand Up @@ -167,7 +169,12 @@ suspend fun deleteOldFiles(

channel.consumeEach { path ->
launch(Dispatchers.IO) {
path.tryToResult { it.deleteIfExists() }.onSuccess {
path.tryToResult {
if (defaultIgnoredPaths.none { ignored -> ignored in it.pathString })
{
it.deleteIfExists()
}
}.onSuccess {
onSuccess(path)
}.onFailure {
onError(it)
Expand Down

0 comments on commit bd17132

Please sign in to comment.