Commit 5420af88 authored by Kirill Smelkov's avatar Kirill Smelkov

Add support for archive.tar.xz

( will send upstream after testing whether it works )
parent d23a3247
Pipeline #1190 failed with stage
......@@ -48,6 +48,8 @@ func (a *archive) Inject(w http.ResponseWriter, r *http.Request, sendData string
format = "tar.gz"
case "archive.tar.bz2":
format = "tar.bz2"
case "archive.tar.xz":
format = "tar.xz"
default:
helper.Fail500(w, fmt.Errorf("handleGetArchive: invalid format: %s", urlPath))
return
......@@ -163,6 +165,8 @@ func parseArchiveFormat(format string) (*exec.Cmd, string) {
return exec.Command("gzip", "-c", "-n"), "tar"
case "tar.bz2":
return exec.Command("bzip2", "-c"), "tar"
case "tar.xz":
return exec.Command("xz", "-c"), "tar"
case "zip":
return nil, "zip"
}
......
......@@ -189,6 +189,25 @@ func TestAllowedDownloadTarBz2(t *testing.T) {
runOrFail(t, extractCmd)
}
func TestAllowedDownloadTarXz(t *testing.T) {
prepareDownloadDir(t)
// Prepare test server and backend
archiveName := "foobar.tar.xz"
ts := archiveOKServer(t, archiveName)
defer ts.Close()
ws := startWorkhorseServer(ts.URL)
defer ws.Close()
downloadCmd := exec.Command("curl", "-J", "-O", fmt.Sprintf("%s/%s/repository/archive.tar.xz", ws.URL, testProject))
downloadCmd.Dir = scratchDir
runOrFail(t, downloadCmd)
extractCmd := exec.Command("tar", "Jxf", archiveName)
extractCmd.Dir = scratchDir
runOrFail(t, extractCmd)
}
func TestAllowedApiDownloadZip(t *testing.T) {
prepareDownloadDir(t)
......
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