Skip to content

Commit 7f2f6fe

Browse files
committed
Remove old strings from setting
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 2b05f9e commit 7f2f6fe

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

cmd/migrate_storage.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ var CmdMigrateStorage = cli.Command{
3232
},
3333
cli.StringFlag{
3434
Name: "storage, s",
35-
Value: setting.LocalStorageType,
36-
Usage: "New storage type, local or minio",
35+
Value: "",
36+
Usage: "New storage type: local (default) or minio",
3737
},
3838
cli.StringFlag{
3939
Name: "path, p",
@@ -116,7 +116,9 @@ func runMigrateStorage(ctx *cli.Context) error {
116116
var dstStorage storage.ObjectStorage
117117
var err error
118118
switch strings.ToLower(ctx.String("storage")) {
119-
case setting.LocalStorageType:
119+
case "":
120+
fallthrough
121+
case string(storage.LocalStorageType):
120122
p := ctx.String("path")
121123
if p == "" {
122124
log.Fatal("Path must be given when storage is loal")
@@ -127,7 +129,7 @@ func runMigrateStorage(ctx *cli.Context) error {
127129
storage.LocalStorageConfig{
128130
Path: p,
129131
})
130-
case setting.MinioStorageType:
132+
case string(storage.MinioStorageType):
131133
dstStorage, err = storage.NewMinioStorage(
132134
goCtx,
133135
storage.MinioStorageConfig{

models/unit_tests.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ func MainTest(m *testing.M, pathToGiteaRoot string) {
6767
if err != nil {
6868
fatalTestError("url.Parse: %v\n", err)
6969
}
70-
setting.Attachment.Storage.Type = setting.LocalStorageType
7170
setting.Attachment.Storage.Path = filepath.Join(setting.AppDataPath, "attachments")
7271

73-
setting.LFS.Storage.Type = setting.LocalStorageType
7472
setting.LFS.Storage.Path = filepath.Join(setting.AppDataPath, "lfs")
7573
if err = storage.Init(); err != nil {
7674
fatalTestError("storage.Init: %v\n", err)

modules/setting/attachment.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ var (
1818
Enabled bool
1919
}{
2020
Storage: Storage{
21-
Type: LocalStorageType,
2221
ServeDirect: false,
2322
},
2423
AllowedTypes: "image/jpeg,image/png,application/zip,application/gzip",

modules/setting/storage.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import (
1111
ini "gopkg.in/ini.v1"
1212
)
1313

14-
// enumerate all storage types
15-
const (
16-
LocalStorageType = "local"
17-
MinioStorageType = "minio"
18-
)
19-
2014
// Storage represents configuration of storages
2115
type Storage struct {
2216
Type string
@@ -52,7 +46,7 @@ func getStorage(name, typ string, overrides ...*ini.Section) Storage {
5246

5347
var storage Storage
5448

55-
storage.Type = sec.Key("STORAGE_TYPE").MustString(LocalStorageType)
49+
storage.Type = sec.Key("STORAGE_TYPE").MustString("")
5650
storage.ServeDirect = sec.Key("SERVE_DIRECT").MustBool(false)
5751

5852
// Global Defaults

modules/storage/storage.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ func Init() error {
101101

102102
// NewStorage takes a storage type and some config and returns an ObjectStorage or an error
103103
func NewStorage(typStr string, cfg interface{}) (ObjectStorage, error) {
104+
if len(typStr) == 0 {
105+
typStr = string(LocalStorageType)
106+
}
104107
fn, ok := storageMap[Type(typStr)]
105108
if !ok {
106109
return nil, fmt.Errorf("Unsupported storage type: %s", typStr)

0 commit comments

Comments
 (0)