diff options
author | 6543 <6543@obermui.de> | 2020-12-25 09:59:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-25 11:59:32 +0200 |
commit | a19447aed128ecadfcd938d6a80cd4951af1f4ce (patch) | |
tree | 6312bf946d601aab29731645a4777feeaea66036 /models/ssh_key.go | |
parent | 04ae0f2f3f4556c6d0b4adc5f2cffd0cc7d25151 (diff) | |
download | gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.tar.gz gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.zip |
migrate from com.* to alternatives (#14103)
* remove github.com/unknwon/com from models
* dont use "com.ToStr()"
* replace "com.ToStr" with "fmt.Sprint" where its easy to do
* more refactor
* fix test
* just "proxy" Copy func for now
* as per @lunny
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r-- | models/ssh_key.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go index f13fc61914..b2e4326559 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -20,6 +20,7 @@ import ( "math/big" "os" "path/filepath" + "strconv" "strings" "sync" "time" @@ -30,7 +31,6 @@ import ( "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" - "github.com/unknwon/com" "golang.org/x/crypto/ssh" "xorm.io/builder" "xorm.io/xorm" @@ -252,7 +252,11 @@ func SSHKeyGenParsePublicKey(key string) (string, int, error) { } keyType := strings.Trim(fields[len(fields)-1], "()\r\n") - return strings.ToLower(keyType), com.StrTo(fields[0]).MustInt(), nil + length, err := strconv.ParseInt(fields[0], 10, 32) + if err != nil { + return "", 0, err + } + return strings.ToLower(keyType), int(length), nil } // SSHNativeParsePublicKey extracts the key type and length using the golang SSH library. @@ -744,7 +748,7 @@ func rewriteAllPublicKeys(e Engine) error { } if isExist { bakPath := fmt.Sprintf("%s_%d.gitea_bak", fPath, time.Now().Unix()) - if err = com.Copy(fPath, bakPath); err != nil { + if err = util.CopyFile(fPath, bakPath); err != nil { return err } } @@ -1226,7 +1230,7 @@ func rewriteAllPrincipalKeys(e Engine) error { } if isExist { bakPath := fmt.Sprintf("%s_%d.gitea_bak", fPath, time.Now().Unix()) - if err = com.Copy(fPath, bakPath); err != nil { + if err = util.CopyFile(fPath, bakPath); err != nil { return err } } |