From 46e6301c4482ebd12714703fed7f1a5bdac48557 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:14:28 +0800 Subject: [PATCH] fix: repo not exist --- cli/repo.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/repo.go b/cli/repo.go index 721ba58..7542f69 100644 --- a/cli/repo.go +++ b/cli/repo.go @@ -97,16 +97,22 @@ func (r *FsRepo) GetDataDir() (string, error) { } func NewFsRepo(repoPath string) (Repo, error) { - afterExpand, err := homedir.Expand(repoPath) + var err error + repoPath, err = homedir.Expand(repoPath) if err != nil { return nil, fmt.Errorf("expand home dir: %w", err) } ret := &FsRepo{ - repoPath: afterExpand, + repoPath: repoPath, configPath: DefaultConfigFile, dataPath: DefaultDataDir, tokenPath: DefaultTokenFile, } + // create repo if not exist + err = makeDir(repoPath) + if err != nil { + return nil, fmt.Errorf("make repo dir: %w", err) + } return ret, nil }