Skip to content

Commit

Permalink
Merge pull request #3 from ernoaapa/return-rpi3-tar
Browse files Browse the repository at this point in the history
Return rpi3 tar package
  • Loading branch information
ernoaapa authored Dec 30, 2017
2 parents ee419a7 + dbfd915 commit 51aa3fa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/api/build.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package api

import (
"archive/tar"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"

"github.com/dockpit/dirtar"
"github.com/ernoaapa/linuxkit-server/pkg/linuxkit"
Expand Down Expand Up @@ -33,8 +34,18 @@ func createBuild(name, format string, w http.ResponseWriter, r *http.Request) {
return
}

tw := tar.NewWriter(w)
defer tw.Close()
if format == "rpi3" {
tar, ferr := os.Open(filepath.Join(tempDir, fmt.Sprintf("%s.tar", name)))
if ferr != nil {
http.Error(w, fmt.Sprintf("Failed to open rpi3 tar file: %s", ferr), 500)
return
}
_, err := io.Copy(w, tar)
if err != nil {
log.Errorf("Error while copying tar file to response: %s", err)
}
return
}

if err := dirtar.Tar(tempDir, w); err != nil {
http.Error(w, err.Error(), 500)
Expand Down

0 comments on commit 51aa3fa

Please sign in to comment.