fix: remove the tempoary theme directory

pull/335/head
raisons 1 year ago committed by 1379Monitor
parent fb2765521b
commit 45d33771c8

@ -10,6 +10,7 @@ import (
"go.uber.org/fx"
"github.com/go-sonic/sonic/model/dto"
"github.com/go-sonic/sonic/util"
"github.com/go-sonic/sonic/util/xerr"
)
@ -25,6 +26,13 @@ func (g gitThemeFetcherImpl) FetchTheme(ctx context.Context, file interface{}) (
tempDir := os.TempDir()
themeDirName := lastSplit
tmpThemeDir := filepath.Join(tempDir, themeDirName)
if util.FileIsExisted(tmpThemeDir) {
err := os.RemoveAll(tmpThemeDir)
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("delete tmp theme directory err")
}
}
_, err := git.PlainClone(filepath.Join(tempDir, themeDirName), false, &git.CloneOptions{
URL: gitURL,
})

Loading…
Cancel
Save