Skip to content

Commit

Permalink
download games into $GRADLE_USER_HOME/mindustry-mgpp/games.
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Dec 11, 2023
1 parent de3d0c1 commit 438e1d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions main/src/io/github/liplum/mindustry/SharedCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ object SharedCache {
}
}

fun resolveCacheDir(): File {
return resolveGradleUserHome().resolve("mindustry-mgpp")
}
val cacheDir: File
get() = resolveGradleUserHome().resolve("mindustry-mgpp")

val modsDir: File
get() = cacheDir.resolve("mods")

val gamesDir: File
get() = cacheDir.resolve("games")

fun cleanCache() {
val dir = resolveCacheDir()
val dir = cacheDir
if (dir.isDirectory) {
dir.deleteRecursively()
}
Expand Down
2 changes: 1 addition & 1 deletion main/src/io/github/liplum/mindustry/task/DownloadGame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ open class DownloadGame : DefaultTask() {
// Download is a very expensive task, it should detect whether the file exists.
if (gameLoc is GitHubGameLoc) {
val downloadLoc = gameLoc.createDownloadLoc()
val cacheFile = SharedCache.resolveCacheDir().resolve("github").resolve(gameLoc.fileName).ensure()
val cacheFile = SharedCache.gamesDir.resolve("github").resolve(gameLoc.fileName).ensure()
if (!cacheFile.exists()) {
logger.lifecycle("Downloading $downloadLoc from ${gameLoc.fileName}...")
try {
Expand Down

0 comments on commit 438e1d6

Please sign in to comment.