diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-05-04 18:48:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-04 18:48:23 +0800 |
commit | 9fd4f5562d7a59abbef5e78d44fb85a0041e0733 (patch) | |
tree | 8b917bfbf8d2c7fb186e832f52f29b5942d43b12 /internal/cmd | |
parent | 9bb218734c53c98a13264c2f4f479e3633ccfe18 (diff) |
all: use semver to compare versions (#6147)
Diffstat (limited to 'internal/cmd')
-rw-r--r-- | internal/cmd/restore.go | 6 |
1 files changed, 3 insertions, 3 deletions
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() |