mirror of https://github.com/sbt/sbt.git
fix: Retry create directory
**Problem** Files.createDirectories can fail. **Solution** Use IO version, which retries.
This commit is contained in:
parent
acd76d29a9
commit
799bd65ba5
|
|
@ -18,7 +18,7 @@ import java.nio.file.{ Files, Path, Paths, StandardOpenOption }
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import scala.jdk.CollectionConverters.*
|
import scala.jdk.CollectionConverters.*
|
||||||
import scala.quoted.*
|
import scala.quoted.*
|
||||||
import sbt.io.Hash
|
import sbt.io.{ Hash, IO }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - nonCpOptions - non-classpath options
|
* - nonCpOptions - non-classpath options
|
||||||
|
|
@ -35,7 +35,7 @@ class Eval(
|
||||||
import Eval.*
|
import Eval.*
|
||||||
|
|
||||||
backingDir.foreach { dir =>
|
backingDir.foreach { dir =>
|
||||||
Files.createDirectories(dir)
|
IO.createDirectory(dir.toFile())
|
||||||
}
|
}
|
||||||
private val outputDir =
|
private val outputDir =
|
||||||
backingDir match
|
backingDir match
|
||||||
|
|
|
||||||
|
|
@ -1200,7 +1200,7 @@ object BuiltinCommands {
|
||||||
try {
|
try {
|
||||||
val version = sbtVersion(state)
|
val version = sbtVersion(state)
|
||||||
val skipFile = skipWelcomeFile(state, version)
|
val skipFile = skipWelcomeFile(state, version)
|
||||||
Files.createDirectories(skipFile.getParent)
|
IO.createDirectory(skipFile.getParent.toFile())
|
||||||
val suppress = !SysProp.banner || Files.exists(skipFile)
|
val suppress = !SysProp.banner || Files.exists(skipFile)
|
||||||
if (!suppress) {
|
if (!suppress) {
|
||||||
Banner(version).foreach(banner => state.log.info(banner))
|
Banner(version).foreach(banner => state.log.info(banner))
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ private[sbt] object InstallSbtn {
|
||||||
|
|
||||||
private[sbt] def extractSbtn(term: Terminal, version: String, sbtZip: Path, sbtn: Path): Unit = {
|
private[sbt] def extractSbtn(term: Terminal, version: String, sbtZip: Path, sbtn: Path): Unit = {
|
||||||
downloadRelease(term, version, sbtZip)
|
downloadRelease(term, version, sbtZip)
|
||||||
Files.createDirectories(sbtn.getParent)
|
IO.createDirectory(sbtn.getParent().toFile())
|
||||||
val bin =
|
val bin =
|
||||||
if (Properties.isWin) "pc-win32.exe"
|
if (Properties.isWin) "pc-win32.exe"
|
||||||
else if (Properties.isLinux) "pc-linux"
|
else if (Properties.isLinux) "pc-linux"
|
||||||
|
|
@ -140,7 +140,7 @@ private[sbt] object InstallSbtn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private def downloadCompletion(completion: String, version: String, target: Path): Unit = {
|
private def downloadCompletion(completion: String, version: String, target: Path): Unit = {
|
||||||
Files.createDirectories(target.getParent)
|
IO.createDirectory(target.getParent().toFile())
|
||||||
val comp = s"https://raw.githubusercontent.com/sbt/sbt/v$version/client/completions/$completion"
|
val comp = s"https://raw.githubusercontent.com/sbt/sbt/v$version/client/completions/$completion"
|
||||||
transfer(new URI(comp).toURL.openStream, target)
|
transfer(new URI(comp).toURL.openStream, target)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ class DiskActionCacheStore(base: Path, converter: FileConverter) extends Abstrac
|
||||||
// On Windows, the program has be running under the Administrator privileges or the
|
// On Windows, the program has be running under the Administrator privileges or the
|
||||||
// user enable Developer Mode on Windows 10+ to create symbolic links.
|
// user enable Developer Mode on Windows 10+ to create symbolic links.
|
||||||
def writeFileAndNotify(outPath: Path): Path =
|
def writeFileAndNotify(outPath: Path): Path =
|
||||||
Files.createDirectories(outPath.getParent())
|
IO.createDirectory(outPath.getParent().toFile())
|
||||||
val result = Retry:
|
val result = Retry:
|
||||||
if Files.exists(outPath) then IO.delete(outPath.toFile())
|
if Files.exists(outPath) then IO.delete(outPath.toFile())
|
||||||
if symlinkSupported.get() then
|
if symlinkSupported.get() then
|
||||||
|
|
@ -314,7 +314,7 @@ class DiskActionCacheStore(base: Path, converter: FileConverter) extends Abstrac
|
||||||
*/
|
*/
|
||||||
private def unpackageDirZip(dirzip: Path, outputDirectory: Path): Path =
|
private def unpackageDirZip(dirzip: Path, outputDirectory: Path): Path =
|
||||||
val dirPath = Paths.get(dirzip.toString.dropRight(ActionCache.dirZipExt.size))
|
val dirPath = Paths.get(dirzip.toString.dropRight(ActionCache.dirZipExt.size))
|
||||||
Files.createDirectories(dirPath)
|
IO.createDirectory(dirPath.toFile())
|
||||||
val allPaths = mutable.Set(
|
val allPaths = mutable.Set(
|
||||||
FileTreeView.default
|
FileTreeView.default
|
||||||
.list(dirPath.toGlob / ** / "*")
|
.list(dirPath.toGlob / ** / "*")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue