Add flag to enable new cache layout

This commit is contained in:
Deluan 2020-10-26 09:54:36 -04:00 committed by Joe Stump
parent 437339b9b2
commit 0aee6b4377
No known key found for this signature in database
GPG Key ID: 29151C3EC48A0EB9
2 changed files with 8 additions and 1 deletions

View File

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

View File

@ -187,8 +187,13 @@ func newFSCache(name, cacheSize, cacheFolder string, maxItems int) (fscache.Cach
h := fscache.NewLRUHaunterStrategy(lru)
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))
fs, err := NewSpreadFS(cacheFolder, 0755)
if conf.Server.DevNewCacheLayout {
fs, err = NewSpreadFS(cacheFolder, 0755)
} else {
fs, err = fscache.NewFs(cacheFolder, 0755)
}
if err != nil {
log.Error(fmt.Sprintf("Error initializing %s cache", name), err, "elapsedTime", time.Since(start))
return nil, err