1
0
Fork 0
forked from forgejo/forgejo

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
This commit is contained in:
6543 2020-12-25 09:59:32 +00:00 committed by GitHub
parent 04ae0f2f3f
commit a19447aed1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 230 additions and 220 deletions

View file

@ -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
}
}