Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow default value for CoverArtCache path #2237

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/jukebox/components/playermpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ def __init__(self):
self.decode_2nd_swipe_option()

self.mpd_client = mpd.MPDClient()

coverart_cache_path = cfg.getn('webapp', 'coverart_cache_path')
self.coverart_cache_manager = CoverartCacheManager(os.path.expanduser(coverart_cache_path))
self.coverart_cache_manager = CoverartCacheManager()

# The timeout refer to the low-level socket time-out
# If these are too short and the response is not fast enough (due to the PI being busy),
Expand Down
8 changes: 6 additions & 2 deletions src/jukebox/components/playermpd/coverart_cache_manager.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import os
import jukebox.cfghandler

cfg = jukebox.cfghandler.get_handler('jukebox')


class CoverartCacheManager:
def __init__(self, cache_folder_path):
self.cache_folder_path = cache_folder_path
def __init__(self):
coverart_cache_path = cfg.setndefault('webapp', 'coverart_cache_path', value='../../src/webapp/build/cover-cache')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering is there a use case where a user needs that path configurable?

Copy link
Collaborator

@Groovylein Groovylein Feb 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question applies on many vars in the yaml.

I assume we can think of the yaml as a global var handler.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering is there a use case where a user needs that path configurable?

It's not required to be configurable, especially now that it is handled in its own class. Yet, it's a best practice at the moment. We might want to review the jukebox.yaml and check, if this could be done differently!

self.cache_folder_path = os.path.expanduser(coverart_cache_path)

def find_file_by_hash(self, hash_value):
for filename in os.listdir(self.cache_folder_path):
Expand Down
Loading