Commit 10b8cbae authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[GUI] fix: download extract path

parent cce9e5c2
......@@ -10,6 +10,7 @@ import org.openmole.gui.server.core.Utils._
import org.openmole.gui.ext.data
import org.openmole.gui.ext.data._
import java.io._
import java.net.URL
import java.nio.file._
import java.util.zip.GZIPInputStream
......@@ -528,8 +529,14 @@ class ApiImpl(s: Services, applicationControl: ApplicationControl) extends Api {
val result =
Try {
gridscale.http.getResponse(url) { response
def extractName = url.split("/").last
val checkedURL =
java.net.URI.create(url).getScheme match {
case null "http://" + url
case _ url
}
gridscale.http.getResponse(checkedURL) { response
def extractName = checkedURL.split("/").last
val name =
response.headers.flatMap {
case ("Content-Disposition", value)
......@@ -539,16 +546,19 @@ class ApiImpl(s: Services, applicationControl: ApplicationControl) extends Api {
}
case _ None
}.headOption.getOrElse(extractName)
val dest = safePathToFile(path / name)(ServerFileSystemContext.project, workspace)
val is = response.inputStream
if (extract) {
val dest = safePathToFile(path)(ServerFileSystemContext.project, workspace)
val tis = new TarInputStream(new GZIPInputStream(is))
try tis.extract(dest)
finally tis.close
}
else dest.withOutputStream(os copy(is, os))
else {
val dest = safePathToFile(path / name)(ServerFileSystemContext.project, workspace)
dest.withOutputStream(os copy(is, os))
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment