From 1dbb925d298572afb09257ba3555374032799580 Mon Sep 17 00:00:00 2001 From: guol-fnst Date: Wed, 15 Jun 2022 15:51:37 +0800 Subject: [PATCH] remove unused function remove log when weed is up to date add check whether weed is full version --- weed/command/update.go | 26 ++++++++++++-------------- weed/command/update_full.go | 9 +++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 weed/command/update_full.go diff --git a/weed/command/update.go b/weed/command/update.go index 945ecc293..3f575d513 100644 --- a/weed/command/update.go +++ b/weed/command/update.go @@ -52,6 +52,9 @@ type githubError struct { Message string } +//default version is not full version +var isFullVersion = false + var ( updateOpt UpdateOptions ) @@ -91,16 +94,11 @@ func runUpdate(cmd *Command, args []string) bool { } } - glog.V(0).Infof("writing weed to %v\n", *updateOpt.Output) - v, err := downloadLatestStableRelease(context.Background(), *updateOpt.Output) if err != nil { - glog.Fatalf("unable to update weed: %v", err) + glog.Fatalf("unable to update weed to version %s: %v", err, v) return false } - - glog.V(0).Infof("successfully updated weed to version %v\n", v) - return true } @@ -123,12 +121,17 @@ func downloadLatestStableRelease(ctx context.Context, target string) (version st largeDiskSuffix = "_large_disk" } + fullSuffix := "" + if isFullVersion { + fullSuffix = "_full" + } + ext := "tar.gz" if runtime.GOOS == "windows" { ext = "zip" } - suffix := fmt.Sprintf("%s_%s%s.%s", runtime.GOOS, runtime.GOARCH, largeDiskSuffix, ext) + suffix := fmt.Sprintf("%s_%s%s%s.%s", runtime.GOOS, runtime.GOARCH, fullSuffix, largeDiskSuffix, ext) md5Filename := fmt.Sprintf("%s.md5", suffix) _, md5Val, err := getGithubDataFile(ctx, rel.Assets, md5Filename) if err != nil { @@ -152,18 +155,13 @@ func downloadLatestStableRelease(ctx context.Context, target string) (version st err = extractToFile(buf, downloadFilename, target) if err != nil { return "", err + } else { + glog.V(0).Infof("successfully updated weed to version %v\n", rel.Version) } return rel.Version, nil } -func (r Release) String() string { - return fmt.Sprintf("%v %v, %d assets", - r.TagName, - r.PublishedAt.Local().Format("2006-01-02 15:04:05"), - len(r.Assets)) -} - // GitHubLatestRelease uses the GitHub API to get information about the latest // release of a repository. func GitHubLatestRelease(ctx context.Context, owner, repo string) (Release, error) { diff --git a/weed/command/update_full.go b/weed/command/update_full.go new file mode 100644 index 000000000..529f38219 --- /dev/null +++ b/weed/command/update_full.go @@ -0,0 +1,9 @@ +//go:build elastic && ydb && gocdk && hdfs +// +build elastic,ydb,gocdk,hdfs + +package command + +//set true if gtags are set +func init() { + isFullVersion = true +}