Remove the downloaded Git installer after using it, and in case of error: IDEA-221692

GitOrigin-RevId: fbb24f89686cff2f1875f3ddad46b0287ea4428c
This commit is contained in:
Kirill Likhodedov
2020-02-09 18:02:26 +03:00
committed by intellij-monorepo-bot
parent 19cba95ae2
commit 996a2c1baf
2 changed files with 29 additions and 18 deletions

View File

@@ -29,16 +29,21 @@ class MacExecutableProblemHandler(val project: Project) : GitExecutableProblemHa
private fun showGenericError(exception: Throwable, errorNotifier: ErrorNotifier, onErrorResolved: () -> Unit) {
errorNotifier.showError("Git is not installed", ErrorNotifier.FixOption.Standard("Download and install") {
errorNotifier.executeTask("Downloading...", false) {
val installer = fetchInstaller(errorNotifier) { it.os == "macOS" }
if (installer != null) {
val fileName = installer.fileName
val dmgFile = File(tempPath, fileName)
val pkgFileName = installer.pkgFileName
if (downloadGit(installer, dmgFile, project, errorNotifier)) {
errorNotifier.changeProgressTitle("Installing...")
installGit(dmgFile, pkgFileName, errorNotifier, onErrorResolved)
try {
val installer = fetchInstaller(errorNotifier) { it.os == "macOS" }
if (installer != null) {
val fileName = installer.fileName
val dmgFile = File(tempPath, fileName)
val pkgFileName = installer.pkgFileName
if (downloadGit(installer, dmgFile, project, errorNotifier)) {
errorNotifier.changeProgressTitle("Installing...")
installGit(dmgFile, pkgFileName, errorNotifier, onErrorResolved)
}
}
}
finally {
FileUtil.delete(tempPath)
}
}
})
}

View File

@@ -7,6 +7,7 @@ import com.intellij.openapi.application.PathManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import java.io.File
internal class WindowsExecutableProblemHandler(val project: Project) : GitExecutableProblemHandler {
@@ -17,18 +18,23 @@ internal class WindowsExecutableProblemHandler(val project: Project) : GitExecut
override fun showError(exception: Throwable, errorNotifier: ErrorNotifier, onErrorResolved: () -> Unit) {
errorNotifier.showError("Git is not installed", ErrorNotifier.FixOption.Standard("Download and install") {
errorNotifier.executeTask("Downloading...", true) {
val installer = fetchInstaller(errorNotifier) { it.os == "windows" && archMatches(it.arch) }
if (installer != null) {
val fileName = installer.fileName
val exeFile = File(PathManager.getTempPath(), fileName)
if (downloadGit(installer, exeFile, project, errorNotifier)) {
errorNotifier.changeProgressTitle("Installing...")
installGit(exeFile, errorNotifier, onErrorResolved)
errorNotifier.executeTask("Downloading...", true) {
val installer = fetchInstaller(errorNotifier) { it.os == "windows" && archMatches(it.arch) }
if (installer != null) {
val fileName = installer.fileName
val exeFile = File(PathManager.getTempPath(), fileName)
try {
if (downloadGit(installer, exeFile, project, errorNotifier)) {
errorNotifier.changeProgressTitle("Installing...")
installGit(exeFile, errorNotifier, onErrorResolved)
}
}
finally {
FileUtil.delete(exeFile)
}
}
}
}
})
})
}
private fun archMatches(arch: String) = if (SystemInfo.is32Bit) arch == "x86_32" else arch == "x86_64"