aboutsummaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-02-29 16:29:17 +0800
committerGitHub <noreply@github.com>2020-02-29 16:29:17 +0800
commit17ae0ed3eef54d96bd179ff7fec0540cf3024748 (patch)
treea9111282717da16feb83baf352ffb2ee5178ca0d /internal/db
parentd59b0f6ff7ee24d94eaa5ad68173405faea6a81c (diff)
conf: overhaul settings (#5953)
* Overhaul cache settings * Overhaul HTTP settings * conf: overhaul more settings * log: make LGTM happy * travis: upload report to Codecov * Add codecov.yml
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/attachment.go2
-rw-r--r--internal/db/migrations/v15.go2
-rw-r--r--internal/db/models.go2
-rw-r--r--internal/db/repo.go4
-rw-r--r--internal/db/user.go6
5 files changed, 8 insertions, 8 deletions
diff --git a/internal/db/attachment.go b/internal/db/attachment.go
index 8d84d8a7..44ac4fe2 100644
--- a/internal/db/attachment.go
+++ b/internal/db/attachment.go
@@ -44,7 +44,7 @@ func (a *Attachment) AfterSet(colName string, _ xorm.Cell) {
// AttachmentLocalPath returns where attachment is stored in local file system based on given UUID.
func AttachmentLocalPath(uuid string) string {
- return path.Join(conf.AttachmentPath, uuid[0:1], uuid[1:2], uuid)
+ return path.Join(conf.Attachment.Path, uuid[0:1], uuid[1:2], uuid)
}
// LocalPath returns where attachment is stored in local file system.
diff --git a/internal/db/migrations/v15.go b/internal/db/migrations/v15.go
index 0631e472..d7cad3cf 100644
--- a/internal/db/migrations/v15.go
+++ b/internal/db/migrations/v15.go
@@ -39,7 +39,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
)
// Cleanup old update.log and http.log files.
- _ = filepath.Walk(conf.LogRootPath, func(path string, info os.FileInfo, err error) error {
+ _ = filepath.Walk(conf.Log.RootPath, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() &&
(strings.HasPrefix(filepath.Base(path), "update.log") ||
strings.HasPrefix(filepath.Base(path), "http.log")) {
diff --git a/internal/db/models.go b/internal/db/models.go
index ae54a2da..212a1f60 100644
--- a/internal/db/models.go
+++ b/internal/db/models.go
@@ -172,7 +172,7 @@ func SetEngine() (err error) {
// WARNING: for serv command, MUST remove the output to os.stdout,
// so use log file to instead print to stdout.
sec := conf.File.Section("log.xorm")
- logger, err := log.NewFileWriter(path.Join(conf.LogRootPath, "xorm.log"),
+ logger, err := log.NewFileWriter(path.Join(conf.Log.RootPath, "xorm.log"),
log.FileRotationConfig{
Rotate: sec.Key("ROTATE").MustBool(true),
Daily: sec.Key("ROTATE_DAILY").MustBool(true),
diff --git a/internal/db/repo.go b/internal/db/repo.go
index ca29e305..e3d881d0 100644
--- a/internal/db/repo.go
+++ b/internal/db/repo.go
@@ -296,7 +296,7 @@ func (repo *Repository) HTMLURL() string {
// CustomAvatarPath returns repository custom avatar file path.
func (repo *Repository) CustomAvatarPath() string {
- return filepath.Join(conf.RepositoryAvatarUploadPath, com.ToStr(repo.ID))
+ return filepath.Join(conf.Picture.RepositoryAvatarUploadPath, com.ToStr(repo.ID))
}
// RelAvatarLink returns relative avatar link to the site domain,
@@ -327,7 +327,7 @@ func (repo *Repository) UploadAvatar(data []byte) error {
return fmt.Errorf("decode image: %v", err)
}
- _ = os.MkdirAll(conf.RepositoryAvatarUploadPath, os.ModePerm)
+ _ = os.MkdirAll(conf.Picture.RepositoryAvatarUploadPath, os.ModePerm)
fw, err := os.Create(repo.CustomAvatarPath())
if err != nil {
return fmt.Errorf("create custom avatar directory: %v", err)
diff --git a/internal/db/user.go b/internal/db/user.go
index adaac99b..603f1905 100644
--- a/internal/db/user.go
+++ b/internal/db/user.go
@@ -216,7 +216,7 @@ func (u *User) GenerateActivateCode() string {
// CustomAvatarPath returns user custom avatar file path.
func (u *User) CustomAvatarPath() string {
- return filepath.Join(conf.AvatarUploadPath, com.ToStr(u.ID))
+ return filepath.Join(conf.Picture.AvatarUploadPath, com.ToStr(u.ID))
}
// GenerateRandomAvatar generates a random avatar for user.
@@ -262,7 +262,7 @@ func (u *User) RelAvatarLink() string {
return defaultImgUrl
}
return fmt.Sprintf("%s/%s/%d", conf.Server.Subpath, USER_AVATAR_URL_PREFIX, u.ID)
- case conf.DisableGravatar:
+ case conf.Picture.DisableGravatar:
if !com.IsExist(u.CustomAvatarPath()) {
if err := u.GenerateRandomAvatar(); err != nil {
log.Error("GenerateRandomAvatar: %v", err)
@@ -341,7 +341,7 @@ func (u *User) UploadAvatar(data []byte) error {
return fmt.Errorf("decode image: %v", err)
}
- _ = os.MkdirAll(conf.AvatarUploadPath, os.ModePerm)
+ _ = os.MkdirAll(conf.Picture.AvatarUploadPath, os.ModePerm)
fw, err := os.Create(u.CustomAvatarPath())
if err != nil {
return fmt.Errorf("create custom avatar directory: %v", err)