Skip to content
Snippets Groups Projects
Commit 8604e22f authored by q3k's avatar q3k
Browse files

apps: fix generated tarballs

parent 78eee03a
No related branches found
No related tags found
No related merge requests found
......@@ -165,22 +165,35 @@ func (s *server) targzApp(ctx context.Context, name, pathInRepo, repo string, ob
prefix = strings.ReplaceAll(repo, "/", "-")
outPath := path.Join(prefix, p)
dirs, _ := path.Split(outPath)
if dirs != "" {
parts := strings.Split(dirs, "/")
cur := parts[0]
for i := 1; i < len(parts); i++ {
cur += parts[i]
if !directories[cur] {
directories[cur] = true
ensureDir := func(p string) error {
if directories[p] {
return nil
}
directories[p] = true
err = t.WriteHeader(&tar.Header{
Name: cur + "/",
Name: p,
Typeflag: tar.TypeDir,
Mode: 0755,
})
if err != nil {
return nil, fmt.Errorf("CreateDir(%q): %w", cur, err)
return fmt.Errorf("CreateDir(%q): %w", p, err)
}
return nil
}
dirs, _ := path.Split(outPath)
if dirs != "" {
dirs = strings.TrimRight(dirs, "/")
parts := strings.Split(dirs, "/")
cur := parts[0] + "/"
if err := ensureDir(cur); err != nil {
return nil, err
}
for i := 1; i < len(parts); i++ {
cur += parts[i] + "/"
if err := ensureDir(cur); err != nil {
return nil, err
}
}
}
......@@ -365,7 +378,7 @@ func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string) (*appI
// app. This is based on md5 so ambitious hack3rs can force a certain
// app seed :)
flow3rSeedMd5 := md5.Sum([]byte(repo))
app.flow3rSeed = "";
app.flow3rSeed = ""
for i := 0; i < 8; i++ {
app.flow3rSeed += string(flow3rSeedMd5[i]%5 + byte('0'))
}
......@@ -481,7 +494,7 @@ type jsonApp struct {
Flow3rSeed string `json:"flow3rSeed"`
}
func makeJsonApp(a *appDescriptor) (jsonApp) {
func makeJsonApp(a *appDescriptor) jsonApp {
return jsonApp{
RepoURL: "https://git.flow3r.garden/" + a.repository,
Commit: a.appInfo.commit,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment