Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FileAlreadyExistsException when copying jars into the instance cache #75

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package workers.common
import xsbti.compile.ScalaInstance
import java.io.File
import java.net.URLClassLoader
import java.nio.file.{Files, Path, Paths}
import java.nio.file.{FileAlreadyExistsException, Files, Path, Paths}
import java.util.Properties
import java.util.concurrent.ConcurrentHashMap
import scala.collection.immutable.TreeMap
Expand Down Expand Up @@ -110,8 +110,14 @@ object AnnexScalaInstance {
// Copying a file is not atomic, so we don't want to end up in a funky state where two
// copies of the same file happen at the same time and cause something bad to happen.
if (!Files.exists(workerJar)) {
Files.createDirectories(workerJar.getParent())
Files.copy(workRequestJar, workerJar)
try {
Files.createDirectories(workerJar.getParent())
Files.copy(workRequestJar, workerJar)
} catch {
// We do not care if the file already exists
case _: FileAlreadyExistsException => {}
case e: Throwable => throw new Exception("Error adding file to instance cache", e)
}
}
}
}
Expand Down