Skip to content

Commit 67f9219

Browse files
committed
do not use deprecatedSettingFatal for cosmetic reasons
It breaks existing instances that would otherwise work perfectly fine. Failing to start an instance should only happen when there is a compelling reason to do so, for instance if the `app.ini` could not be modified in a way that is backward compatible. If the only motivation is to remove the setting for cosmetic reason, it must not be fatal. Refs: https://codeberg.org/forgejo/forgejo/issues/1081
1 parent cf46711 commit 67f9219

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

modules/setting/config_provider.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,6 @@ func deprecatedSetting(rootCfg ConfigProvider, oldSection, oldKey, newSection, n
322322
}
323323
}
324324

325-
func deprecatedSettingFatal(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) {
326-
if rootCfg.Section(oldSection).HasKey(oldKey) {
327-
log.Fatal("Deprecated fallback `[%s]` `%s` present. Use `[%s]` `%s` instead. This fallback will be/has been removed in %s. Shutting down", oldSection, oldKey, newSection, newKey, version)
328-
}
329-
}
330-
331325
// deprecatedSettingDB add a hint that the configuration has been moved to database but still kept in app.ini
332326
func deprecatedSettingDB(rootCfg ConfigProvider, oldSection, oldKey string) {
333327
if rootCfg.Section(oldSection).HasKey(oldKey) {

modules/setting/lfs.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ func loadLFSFrom(rootCfg ConfigProvider) error {
3434
// Specifically default PATH to LFS_CONTENT_PATH
3535
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
3636
// if these are removed, the warning will not be shown
37-
deprecatedSettingFatal(rootCfg, "server", "LFS_CONTENT_PATH", "lfs", "PATH", "v1.19.0")
37+
deprecatedSetting(rootCfg, "server", "LFS_CONTENT_PATH", "lfs", "PATH", "v1.19.0")
38+
39+
if val := sec.Key("LFS_CONTENT_PATH").String(); val != "" {
40+
if lfsSec == nil {
41+
lfsSec = rootCfg.Section("lfs")
42+
}
43+
lfsSec.Key("PATH").MustString(val)
44+
}
3845

3946
var err error
4047
LFS.Storage, err = getStorage(rootCfg, "lfs", "", lfsSec)

modules/setting/lfs_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ func Test_getStorageInheritNameSectionTypeForLFS(t *testing.T) {
2121
assert.EqualValues(t, "minio", LFS.Storage.Type)
2222
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
2323

24+
iniStr = `
25+
[server]
26+
LFS_CONTENT_PATH = path_ignored
27+
[lfs]
28+
PATH = path_used
29+
`
30+
cfg, err = NewConfigProviderFromData(iniStr)
31+
assert.NoError(t, err)
32+
assert.NoError(t, loadLFSFrom(cfg))
33+
34+
assert.EqualValues(t, "local", LFS.Storage.Type)
35+
assert.Contains(t, LFS.Storage.Path, "path_used")
36+
37+
iniStr = `
38+
[server]
39+
LFS_CONTENT_PATH = deprecatedpath
40+
`
41+
cfg, err = NewConfigProviderFromData(iniStr)
42+
assert.NoError(t, err)
43+
assert.NoError(t, loadLFSFrom(cfg))
44+
45+
assert.EqualValues(t, "local", LFS.Storage.Type)
46+
assert.Contains(t, LFS.Storage.Path, "deprecatedpath")
47+
2448
iniStr = `
2549
[storage.lfs]
2650
STORAGE_TYPE = minio

0 commit comments

Comments
 (0)