fix noavatar cap bug

This commit is contained in:
Azareal 2020-12-18 07:13:31 +10:00
parent 79055994bd
commit 08be6ca402
1 changed files with 19 additions and 3 deletions

View File

@ -183,6 +183,11 @@ func LoadConfig() error {
var noavatarCache200 []string var noavatarCache200 []string
var noavatarCache48 []string var noavatarCache48 []string
/*var noavatarCache200Jpg []string
var noavatarCache48Jpg []string
var noavatarCache200Avif []string
var noavatarCache48Avif []string*/
func ProcessConfig() (err error) { func ProcessConfig() (err error) {
// Strip these unnecessary bits, if we find them. // Strip these unnecessary bits, if we find them.
Site.URL = strings.TrimPrefix(Site.URL, "http://") Site.URL = strings.TrimPrefix(Site.URL, "http://")
@ -268,11 +273,22 @@ func ProcessConfig() (err error) {
} }
if !Config.DisableDefaultNoavatar { if !Config.DisableDefaultNoavatar {
noavatarCache200 = make([]string, 10) cap := 11
noavatarCache48 = make([]string, 10) noavatarCache200 = make([]string, cap)
for i := 0; i < 11; i++ { noavatarCache48 = make([]string, cap)
/*noavatarCache200Jpg = make([]string, cap)
noavatarCache48Jpg = make([]string, cap)
noavatarCache200Avif = make([]string, cap)
noavatarCache48Avif = make([]string, cap)*/
for i := 0; i < cap; i++ {
noavatarCache200[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(200) + ".png?i=0" noavatarCache200[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(200) + ".png?i=0"
noavatarCache48[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(48) + ".png?i=0" noavatarCache48[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(48) + ".png?i=0"
/*noavatarCache200Jpg[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(200) + ".jpg?i=0"
noavatarCache48Jpg[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(48) + ".jpg?i=0"
noavatarCache200Avif[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(200) + ".avif?i=0"
noavatarCache48Avif[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(48) + ".avif?i=0"*/
} }
} }
Config.Noavatar = strings.Replace(Config.Noavatar, "{site_url}", Site.URL, -1) Config.Noavatar = strings.Replace(Config.Noavatar, "{site_url}", Site.URL, -1)