Skip to content

Commit

Permalink
[starter eel] AT-1851 Dedicated method for projects cache
Browse files Browse the repository at this point in the history
GitOrigin-RevId: be128dca42964bf2fc983336157db65b527ed6c2
  • Loading branch information
Nikita-Kudrin authored and intellij-monorepo-bot committed Feb 7, 2025
1 parent 99e8a82 commit 17ccb7a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ class GitProjectDownloadingTest {
projectPath.shouldExist()

val globalPaths by di.instance<GlobalPaths>()
projectPath.parent.shouldBe(globalPaths.getCacheDirectoryFor("projects").resolve("unpacked"))
projectPath.parent.shouldBe(globalPaths.cacheDirForProjects.resolve("unpacked"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ abstract class GlobalPaths(val checkoutDir: Path) {
(testHomePath / "cache").createDirectories()
}

/** Cache directory on local or remote machine/target/environment */
/**
* Cache directory on local or remote machine/target/environment (depends on the configuration of the test)
*/
open val cacheDirectory = localCacheDirectory

fun getCacheDirectoryFor(entity: String): Path = (cacheDirectory / entity).createDirectories()

val cacheDirForProjects: Path get() = getCacheDirectoryFor("projects")

companion object {
val instance: GlobalPaths
get() = di.direct.instance<GlobalPaths>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ data class GitProjectInfo(
private val remoteRepositoryRootDir: Path
get() {
val globalPaths by di.instance<GlobalPaths>()
val projectsUnpacked = globalPaths.getCacheDirectoryFor("projects").resolve("unpacked").createDirectories()
val projectsUnpacked = globalPaths.cacheDirForProjects.resolve("unpacked").createDirectories()
return projectsUnpacked.resolve(repositoryUrl.split("/").last().split(".git").first())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ data class RemoteArchiveProjectInfo(
override fun downloadAndUnpackProject(): Path {
val globalPaths by di.instance<GlobalPaths>()

val projectsUnpacked = globalPaths.getCacheDirectoryFor("projects").resolve("unpacked").createDirectories()
val projectsUnpacked = globalPaths.cacheDirForProjects.resolve("unpacked").createDirectories()

val zipFile = globalPaths.getCacheDirectoryFor("projects").resolve("zip").resolve(projectURL.transformUrlToZipName())
val zipFile = globalPaths.cacheDirForProjects.resolve("zip").resolve(projectURL.transformUrlToZipName())

HttpClient.downloadIfMissing(url = projectURL, targetFile = zipFile, timeout = downloadTimeout)
val imagePath: Path = zipFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ReusableLocalProjectInfo(
return null
}

val projectsUnpacked = globalPaths.getCacheDirectoryFor("projects").resolve("unpacked").createDirectories()
val projectsUnpacked = globalPaths.cacheDirForProjects.resolve("unpacked").createDirectories()
val projectHome = projectsUnpacked / projectDir.last().name

val isDeleted = projectHome.toFile().deleteRecursively()
Expand Down

0 comments on commit 17ccb7a

Please sign in to comment.