mirror of
https://github.com/gogs/gogs.git
synced 2026-08-02 04:40:51 +02:00
all: rename packages ending with "util" to end with "x" (#8182)
Co-authored-by: JSS <jss@unknwon.dev> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/database"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/osx"
|
||||
)
|
||||
|
||||
var backupCommand = cli.Command{
|
||||
@@ -59,7 +59,7 @@ func runBackup(ctx context.Context, cmd *cli.Command) error {
|
||||
}
|
||||
|
||||
tmpDir := cmd.String("tempdir")
|
||||
if !osutil.Exist(tmpDir) {
|
||||
if !osx.Exist(tmpDir) {
|
||||
log.Fatal("'--tempdir' does not exist: %s", tmpDir)
|
||||
}
|
||||
rootDir, err := os.MkdirTemp(tmpDir, "gogs-backup-")
|
||||
@@ -108,7 +108,7 @@ func runBackup(ctx context.Context, cmd *cli.Command) error {
|
||||
// Data files
|
||||
for _, dir := range []string{"ssh", "attachments", "avatars", "repo-avatars"} {
|
||||
dirPath := filepath.Join(conf.Server.AppDataPath, dir)
|
||||
if !osutil.IsDir(dirPath) {
|
||||
if !osx.IsDir(dirPath) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"gogs.io/gogs/internal/database"
|
||||
"gogs.io/gogs/internal/email"
|
||||
"gogs.io/gogs/internal/httplib"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/osx"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -133,7 +133,7 @@ func runHookPreReceive(_ context.Context, cmd *cli.Command) error {
|
||||
}
|
||||
|
||||
customHooksPath := filepath.Join(os.Getenv(database.EnvRepoCustomHooksPath), "pre-receive")
|
||||
if !osutil.IsFile(customHooksPath) {
|
||||
if !osx.IsFile(customHooksPath) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ func runHookUpdate(_ context.Context, cmd *cli.Command) error {
|
||||
}
|
||||
|
||||
customHooksPath := filepath.Join(os.Getenv(database.EnvRepoCustomHooksPath), "update")
|
||||
if !osutil.IsFile(customHooksPath) {
|
||||
if !osx.IsFile(customHooksPath) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ func runHookPostReceive(_ context.Context, cmd *cli.Command) error {
|
||||
}
|
||||
|
||||
customHooksPath := filepath.Join(os.Getenv(database.EnvRepoCustomHooksPath), "post-receive")
|
||||
if !osutil.IsFile(customHooksPath) {
|
||||
if !osx.IsFile(customHooksPath) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/urfave/cli/v3"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/osx"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -45,9 +45,9 @@ func runImportLocale(_ context.Context, cmd *cli.Command) error {
|
||||
} else if !cmd.IsSet("target") {
|
||||
return errors.New("target directory is not specified")
|
||||
}
|
||||
if !osutil.IsDir(cmd.String("source")) {
|
||||
if !osx.IsDir(cmd.String("source")) {
|
||||
return errors.Newf("source directory %q does not exist or is not a directory", cmd.String("source"))
|
||||
} else if !osutil.IsDir(cmd.String("target")) {
|
||||
} else if !osx.IsDir(cmd.String("target")) {
|
||||
return errors.Newf("target directory %q does not exist or is not a directory", cmd.String("target"))
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func runImportLocale(_ context.Context, cmd *cli.Command) error {
|
||||
name := fmt.Sprintf("locale_%s.ini", lang)
|
||||
source := filepath.Join(cmd.String("source"), name)
|
||||
target := filepath.Join(cmd.String("target"), name)
|
||||
if !osutil.IsFile(source) {
|
||||
if !osx.IsFile(source) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/database"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/semverutil"
|
||||
"gogs.io/gogs/internal/osx"
|
||||
"gogs.io/gogs/internal/semverx"
|
||||
)
|
||||
|
||||
var restoreCommand = cli.Command{
|
||||
@@ -46,7 +46,7 @@ func runRestore(ctx context.Context, cmd *cli.Command) error {
|
||||
zip.Verbose = cmd.Bool("verbose")
|
||||
|
||||
tmpDir := cmd.String("tempdir")
|
||||
if !osutil.IsDir(tmpDir) {
|
||||
if !osx.IsDir(tmpDir) {
|
||||
log.Fatal("'--tempdir' does not exist: %s", tmpDir)
|
||||
}
|
||||
archivePath := path.Join(tmpDir, archiveRootDir)
|
||||
@@ -66,7 +66,7 @@ func runRestore(ctx context.Context, cmd *cli.Command) error {
|
||||
|
||||
// Check backup version
|
||||
metaFile := filepath.Join(archivePath, "metadata.ini")
|
||||
if !osutil.IsFile(metaFile) {
|
||||
if !osx.IsFile(metaFile) {
|
||||
log.Fatal("File 'metadata.ini' is missing")
|
||||
}
|
||||
metadata, err := ini.Load(metaFile)
|
||||
@@ -74,7 +74,7 @@ func runRestore(ctx context.Context, cmd *cli.Command) error {
|
||||
log.Fatal("Failed to load metadata '%s': %v", metaFile, err)
|
||||
}
|
||||
backupVersion := metadata.Section("").Key("GOGS_VERSION").MustString("999.0")
|
||||
if semverutil.Compare(conf.App.Version, "<", backupVersion) {
|
||||
if semverx.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()
|
||||
@@ -92,7 +92,7 @@ func runRestore(ctx context.Context, cmd *cli.Command) error {
|
||||
var customConf string
|
||||
if lineageConf := configFromLineage(cmd); lineageConf != "" {
|
||||
customConf = lineageConf
|
||||
} else if !osutil.IsFile(configFile) {
|
||||
} else if !osx.IsFile(configFile) {
|
||||
log.Fatal("'--config' is not specified and custom config file is not found in backup")
|
||||
} else {
|
||||
customConf = configFile
|
||||
@@ -117,7 +117,7 @@ func runRestore(ctx context.Context, cmd *cli.Command) error {
|
||||
|
||||
if !cmd.Bool("database-only") {
|
||||
// Custom files
|
||||
if osutil.IsDir(conf.CustomDir()) {
|
||||
if osx.IsDir(conf.CustomDir()) {
|
||||
if err = os.Rename(conf.CustomDir(), conf.CustomDir()+".bak"); err != nil {
|
||||
log.Fatal("Failed to backup current 'custom': %v", err)
|
||||
}
|
||||
@@ -131,12 +131,12 @@ func runRestore(ctx context.Context, cmd *cli.Command) error {
|
||||
for _, dir := range []string{"attachments", "avatars", "repo-avatars"} {
|
||||
// Skip if backup archive does not have corresponding data
|
||||
srcPath := filepath.Join(archivePath, "data", dir)
|
||||
if !osutil.IsDir(srcPath) {
|
||||
if !osx.IsDir(srcPath) {
|
||||
continue
|
||||
}
|
||||
|
||||
dirPath := filepath.Join(conf.Server.AppDataPath, dir)
|
||||
if osutil.IsDir(dirPath) {
|
||||
if osx.IsDir(dirPath) {
|
||||
if err = os.Rename(dirPath, dirPath+".bak"); err != nil {
|
||||
log.Fatal("Failed to backup current 'data': %v", err)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func runRestore(ctx context.Context, cmd *cli.Command) error {
|
||||
|
||||
// Repositories
|
||||
reposPath := filepath.Join(archivePath, "repositories.zip")
|
||||
if !cmd.Bool("exclude-repos") && !cmd.Bool("database-only") && osutil.IsFile(reposPath) {
|
||||
if !cmd.Bool("exclude-repos") && !cmd.Bool("database-only") && osx.IsFile(reposPath) {
|
||||
if err := zip.ExtractTo(reposPath, filepath.Dir(conf.Repository.Root)); err != nil {
|
||||
log.Fatal("Failed to extract 'repositories.zip': %v", err)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/database"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/osx"
|
||||
"gogs.io/gogs/internal/route"
|
||||
"gogs.io/gogs/internal/route/admin"
|
||||
apiv1 "gogs.io/gogs/internal/route/api/v1"
|
||||
@@ -308,7 +308,7 @@ func runWeb(_ stdctx.Context, cmd *cli.Command) error {
|
||||
if err != nil {
|
||||
c.NotFoundOrError(err, "get attachment by UUID")
|
||||
return
|
||||
} else if !osutil.IsFile(attach.LocalPath()) {
|
||||
} else if !osx.IsFile(attach.LocalPath()) {
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
@@ -750,7 +750,7 @@ func runWeb(_ stdctx.Context, cmd *cli.Command) error {
|
||||
err = fcgi.Serve(nil, m)
|
||||
|
||||
case "unix":
|
||||
if osutil.Exist(listenAddr) {
|
||||
if osx.Exist(listenAddr) {
|
||||
err = os.Remove(listenAddr)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to remove existing Unix domain socket: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user