mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 08:31:27 -05:00
f6ba73de4c
Refs: https://forgejo.org/2023-08-release-v1-20-3-0/ (cherry picked from commita266dd0ce3
) (cherry picked from commitb9eb5eccd8
) (cherry picked from commit7fc2028ede
) (cherry picked from commit0c988e6120
) (cherry picked from commit7ba05e8c2b
) (cherry picked from commit2ed5068abe
) (cherry picked from commit353913a26d
) (cherry picked from commit4e63a01a8b
) (cherry picked from commit99f612aed3
) (cherry picked from commitb4fe189cae
) (cherry picked from commitbd35e3b7bc
) (cherry picked from commitf59d9f7088
) (cherry picked from commit0b2a93e044
) (cherry picked from commit8c5d8bfea0
) (cherry picked from commit2817ce027c
) (cherry picked from commit162056cbcf
) (cherry picked from commit07152a0ba6
) (cherry picked from commit72e3777915
) (cherry picked from commit3b1ebd95b9
) (cherry picked from commit14fc4f3fac
) (cherry picked from commit9052c86e8c
) (cherry picked from commit16f1cc21ea
) (cherry picked from commit0fef12f5d8
) (cherry picked from commitd187381f73
) (cherry picked from commit9dda715111
)
91 lines
2.5 KiB
Go
91 lines
2.5 KiB
Go
// SPDX-License-Identifier: MIT
|
|
|
|
package forgejo
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
"code.gitea.io/gitea/models/forgejo/semver"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
)
|
|
|
|
var v1TOv5_0_1IncludedStorageSections = []struct {
|
|
section string
|
|
storageSection string
|
|
}{
|
|
{"attachment", "storage.attachments"},
|
|
{"lfs", "storage.lfs"},
|
|
{"avatar", "storage.avatars"},
|
|
{"repo-avatar", "storage.repo-avatars"},
|
|
{"repo-archive", "storage.repo-archive"},
|
|
{"packages", "storage.packages"},
|
|
// the actions sections are not included here because they were experimental at the time
|
|
}
|
|
|
|
func v1TOv5_0_1Included(e db.Engine, dbVersion int64, cfg setting.ConfigProvider) error {
|
|
//
|
|
// When upgrading from Forgejo > v5 or Gitea > v1.20, no sanity check is necessary
|
|
//
|
|
if dbVersion > ForgejoV5DatabaseVersion {
|
|
return nil
|
|
}
|
|
|
|
//
|
|
// When upgrading from a Forgejo point version >= v5.0.1, no sanity
|
|
// check is necessary
|
|
//
|
|
// When upgrading from a Gitea >= v1.20 the sanitiy checks will
|
|
// always be done They are necessary for Gitea [v1.20.0..v1.20.2]
|
|
// but not for [v1.20.3..] but there is no way to know which point
|
|
// release was running prior to the upgrade. This may require the
|
|
// Gitea admin to update their app.ini although it is not necessary
|
|
// but will have no other consequence.
|
|
//
|
|
previousServerVersion, err := semver.GetVersionWithEngine(e)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
upper, err := version.NewVersion("v5.0.1")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if previousServerVersion.GreaterThan(upper) {
|
|
return nil
|
|
}
|
|
|
|
//
|
|
// Sanity checks
|
|
//
|
|
|
|
originalCfg, err := cfg.PrepareSaving()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
messages := make([]string, 0, 10)
|
|
for _, c := range v1TOv5_0_1IncludedStorageSections {
|
|
section, _ := originalCfg.GetSection(c.section)
|
|
if section == nil {
|
|
continue
|
|
}
|
|
storageSection, _ := originalCfg.GetSection(c.storageSection)
|
|
if storageSection == nil {
|
|
continue
|
|
}
|
|
messages = append(messages, fmt.Sprintf("[%s] and [%s] may conflict with each other", c.section, c.storageSection))
|
|
}
|
|
|
|
if originalCfg.Section("storage").HasKey("PATH") {
|
|
messages = append(messages, "[storage].PATH is set and may create storage issues")
|
|
}
|
|
|
|
if len(messages) > 0 {
|
|
return fatal(fmt.Errorf("%s\nThese issues need to be manually fixed in the app.ini file at %s. Please read https://forgejo.org/2023-08-release-v1-20-3-0/ for instructions", strings.Join(messages, "\n"), cfg.GetFile()))
|
|
}
|
|
return nil
|
|
}
|