Allow configuring cache folder (#2357)
* Set all clients to dev_download for make get-music * Use multiple TranscodingCache instances in tests This fixes flaky tests. The issue is that the TranscodingCache object was being reused in tests from media_stream_Internal_test.go and media_stream_test.go. If tests from the former was run first, the cache would be filled up, so that when running tests from the latter, the `NON seekable` test would fail. * Allow configuring cache folder This commit introduces a new configuration option to configure the cache folder. This allows the cache to be in a separate folder such as /var/cache/navidrome on Linux distributions. * Fix tests * Removed unused test setup code --------- Co-authored-by: Deluan <deluan@deluan.com> Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Vendored
+1
-1
@@ -209,7 +209,7 @@ func newFSCache(name, cacheSize, cacheFolder string, maxItems int) (fscache.Cach
|
||||
|
||||
lru := NewFileHaunter(name, maxItems, int64(size), consts.DefaultCacheCleanUpInterval)
|
||||
h := fscache.NewLRUHaunterStrategy(lru)
|
||||
cacheFolder = filepath.Join(conf.Server.DataFolder, cacheFolder)
|
||||
cacheFolder = filepath.Join(conf.Server.CacheFolder, cacheFolder)
|
||||
|
||||
var fs *spreadFS
|
||||
log.Info(fmt.Sprintf("Creating %s cache", name), "path", cacheFolder, "maxSize", humanize.Bytes(size))
|
||||
|
||||
Vendored
+2
-2
@@ -28,14 +28,14 @@ var _ = Describe("File Caches", func() {
|
||||
configtest.SetupConfig()
|
||||
_ = os.RemoveAll(tmpDir)
|
||||
})
|
||||
conf.Server.DataFolder = tmpDir
|
||||
conf.Server.CacheFolder = tmpDir
|
||||
})
|
||||
|
||||
Describe("NewFileCache", func() {
|
||||
It("creates the cache folder", func() {
|
||||
Expect(callNewFileCache("test", "1k", "test", 0, nil)).ToNot(BeNil())
|
||||
|
||||
_, err := os.Stat(filepath.Join(conf.Server.DataFolder, "test"))
|
||||
_, err := os.Stat(filepath.Join(conf.Server.CacheFolder, "test"))
|
||||
Expect(os.IsNotExist(err)).To(BeFalse())
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user