mirror of https://github.com/Xhofe/alist
				
				
				
			fix: some settings don't take effect at startup
							parent
							
								
									539c47bd3b
								
							
						
					
					
						commit
						a570e4c7a0
					
				| 
						 | 
				
			
			@ -34,7 +34,7 @@ func initSettings() {
 | 
			
		|||
	// insert new items
 | 
			
		||||
	for i := range initialSettingItems {
 | 
			
		||||
		v := initialSettingItems[i]
 | 
			
		||||
		_, err := db.GetSettingItemByKey(v.Key)
 | 
			
		||||
		stored, err := db.GetSettingItemByKey(v.Key)
 | 
			
		||||
		if errors.Is(err, gorm.ErrRecordNotFound) || v.Key == conf.VERSION {
 | 
			
		||||
			err = db.SaveSettingItem(v)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +42,11 @@ func initSettings() {
 | 
			
		|||
			}
 | 
			
		||||
		} else if err != nil {
 | 
			
		||||
			log.Fatalf("failed get setting: %+v", err)
 | 
			
		||||
		} else {
 | 
			
		||||
			err = db.SaveSettingItem(*stored)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("failed resave setting: %+v", err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +112,7 @@ func InitialSettings() []model.SettingItem {
 | 
			
		|||
		// global settings
 | 
			
		||||
		{Key: conf.HideFiles, Value: "/\\/README.md/i", Type: conf.TypeText, Group: model.GLOBAL},
 | 
			
		||||
		{Key: "package_download", Value: "true", Type: conf.TypeBool, Group: model.GLOBAL},
 | 
			
		||||
        {Key: conf.CustomizeHead,Value:`<script src="https://polyfill.io/v3/polyfill.min.js?features=String.prototype.replaceAll"></script>`, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
 | 
			
		||||
		{Key: conf.CustomizeHead, Value: `<script src="https://polyfill.io/v3/polyfill.min.js?features=String.prototype.replaceAll"></script>`, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
 | 
			
		||||
		{Key: conf.CustomizeBody, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
 | 
			
		||||
		{Key: conf.LinkExpiration, Value: "0", Type: conf.TypeNumber, Group: model.GLOBAL, Flag: model.PRIVATE},
 | 
			
		||||
		{Key: conf.PrivacyRegs, Value: `(?:(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue