// extractGitBareZip extracts git-bare.zip to repository path. func extractGitBareZip(repoPath string) error { z, err := zip.Open(path.Join(setting.RepoRootPath, "git-bare.zip")) if err != nil { return err } defer z.Close() return z.ExtractTo(repoPath) }
// extractGitBareZip extracts git-bare.zip to repository path. func extractGitBareZip(repoPath string) error { z, err := zip.Open("conf/content/git-bare.zip") if err != nil { return err } defer z.Close() return z.ExtractTo(repoPath) }
func ExtractBundleBytes() { // origin from https://github.com/wendal/gor/blob/master/gor/gor.go decoder := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(zipBytes)) b, _ := ioutil.ReadAll(decoder) ioutil.WriteFile(tmpZipFile, b, os.ModePerm) z, e := zip.Open(tmpZipFile) if e != nil { panic(e) os.Exit(1) } z.ExtractTo("") defer func() { z.Close() decoder = nil os.Remove(tmpZipFile) }() }
// new site assets func NewSiteAsset(ctx *cli.Context) { zip.Verbose = false tmpZipFile := "tmp.zip" decoder := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(zipBytes)) b, _ := ioutil.ReadAll(decoder) if err := ioutil.WriteFile(tmpZipFile, b, os.ModePerm); err != nil { log.Fatal("NewSite | %s", err.Error()) } z, err := zip.Open(tmpZipFile) if err != nil { log.Fatal("NewSite | %s", err.Error()) } z.ExtractTo("") z.Close() decoder = nil os.Remove(tmpZipFile) log.Info("NewSite | %-8s | Success", "Asset") }
func DoInstall() { // origin from https://github.com/wendal/gor/blob/master/gor/gor.go decoder := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(zipBytes)) b, _ := ioutil.ReadAll(decoder) ioutil.WriteFile(tmpZipFile, b, os.ModePerm) z, e := zip.Open(tmpZipFile) if e != nil { panic(e) os.Exit(1) } z.ExtractTo("") defer func() { z.Close() decoder = nil os.Remove(tmpZipFile) }() ioutil.WriteFile(installLockFile, []byte(fmt.Sprint(utils.Now())), os.ModePerm) println("install success") }