From 9fd4f5562d7a59abbef5e78d44fb85a0041e0733 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Mon, 4 May 2020 18:48:23 +0800 Subject: all: use semver to compare versions (#6147) --- internal/cmd/restore.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/cmd') diff --git a/internal/cmd/restore.go b/internal/cmd/restore.go index ba72c6da..1b6cdf2c 100644 --- a/internal/cmd/restore.go +++ b/internal/cmd/restore.go @@ -9,7 +9,6 @@ import ( "path" "path/filepath" - "github.com/mcuadros/go-version" "github.com/pkg/errors" "github.com/unknwon/cae/zip" "github.com/unknwon/com" @@ -19,6 +18,7 @@ import ( "gogs.io/gogs/internal/conf" "gogs.io/gogs/internal/db" + "gogs.io/gogs/internal/semverutil" ) var Restore = cli.Command{ @@ -58,7 +58,7 @@ func runRestore(c *cli.Context) error { log.Fatal("Failed to extract backup archive: %v", err) } archivePath := path.Join(tmpDir, archiveRootDir) - defer os.RemoveAll(archivePath) + defer func() { _ = os.RemoveAll(archivePath) }() // Check backup version metaFile := filepath.Join(archivePath, "metadata.ini") @@ -70,7 +70,7 @@ func runRestore(c *cli.Context) error { log.Fatal("Failed to load metadata '%s': %v", metaFile, err) } backupVersion := metadata.Section("").Key("GOGS_VERSION").MustString("999.0") - if version.Compare(conf.App.Version, backupVersion, "<") { + if semverutil.Compare(conf.App.Version, "<", backupVersion) { log.Fatal("Current Gogs version is lower than backup version: %s < %s", conf.App.Version, backupVersion) } formatVersion := metadata.Section("").Key("VERSION").MustInt() -- cgit v1.2.3