Add flag to enable new cache layout

This commit is contained in:
Deluan 2020-10-26 09:54:36 -04:00
parent 81d7556cdf
commit bf5318d776
2 changed files with 8 additions and 1 deletions

View File

@ -49,6 +49,7 @@ type configOptions struct {
DevLogSourceLine bool DevLogSourceLine bool
DevAutoCreateAdminPassword string DevAutoCreateAdminPassword string
DevPreCacheAlbumArtwork bool DevPreCacheAlbumArtwork bool
DevNewCacheLayout bool
} }
type scannerOptions struct { type scannerOptions struct {
@ -134,6 +135,7 @@ func init() {
viper.SetDefault("devlogsourceline", false) viper.SetDefault("devlogsourceline", false)
viper.SetDefault("devautocreateadminpassword", "") viper.SetDefault("devautocreateadminpassword", "")
viper.SetDefault("devprecachealbumartwork", false) viper.SetDefault("devprecachealbumartwork", false)
viper.SetDefault("devnewcachelayout", false)
} }
func InitConfig(cfgFile string) { func InitConfig(cfgFile string) {

View File

@ -187,8 +187,13 @@ func newFSCache(name, cacheSize, cacheFolder string, maxItems int) (fscache.Cach
h := fscache.NewLRUHaunterStrategy(lru) h := fscache.NewLRUHaunterStrategy(lru)
cacheFolder = filepath.Join(conf.Server.DataFolder, cacheFolder) cacheFolder = filepath.Join(conf.Server.DataFolder, cacheFolder)
var fs fscache.FileSystem
log.Info(fmt.Sprintf("Creating %s cache", name), "path", cacheFolder, "maxSize", humanize.Bytes(size)) log.Info(fmt.Sprintf("Creating %s cache", name), "path", cacheFolder, "maxSize", humanize.Bytes(size))
fs, err := NewSpreadFS(cacheFolder, 0755) if conf.Server.DevNewCacheLayout {
fs, err = NewSpreadFS(cacheFolder, 0755)
} else {
fs, err = fscache.NewFs(cacheFolder, 0755)
}
if err != nil { if err != nil {
log.Error(fmt.Sprintf("Error initializing %s cache", name), err, "elapsedTime", time.Since(start)) log.Error(fmt.Sprintf("Error initializing %s cache", name), err, "elapsedTime", time.Since(start))
return nil, err return nil, err