diff --git a/src/music_kraken/__init__.py b/src/music_kraken/__init__.py index b3ee566..57106fc 100644 --- a/src/music_kraken/__init__.py +++ b/src/music_kraken/__init__.py @@ -4,12 +4,13 @@ import sys from .utils.shared import DEBUG, DEBUG_LOGGING from .utils.config import logging_settings, main_settings, read_config + read_config() from . import cli - if DEBUG: import sys + sys.setrecursionlimit(100) diff --git a/src/music_kraken/__main__.py b/src/music_kraken/__main__.py index 0425d5d..9da441d 100644 --- a/src/music_kraken/__main__.py +++ b/src/music_kraken/__main__.py @@ -79,6 +79,18 @@ def cli(): action="store_true" ) + parser.add_argument( + "--clear-cache", + help="Deletes the cache.", + action="store_true" + ) + + parser.add_argument( + "--clean-cache", + help="Deletes the outdated cache. (all expired cached files, and not indexed files)", + action="store_true" + ) + arguments = parser.parse_args() if arguments.verbose or arguments.test: @@ -112,6 +124,12 @@ def cli(): if arguments.frontend: cli.set_frontend(silent=False) + if arguments.clear_cache: + cli.clear_cache() + + if arguments.clean_cache: + cli.clean_cache() + # getting the genre genre: str = arguments.genre if arguments.test: diff --git a/src/music_kraken/cli/options/cache.py b/src/music_kraken/cli/options/cache.py new file mode 100644 index 0000000..103696b --- /dev/null +++ b/src/music_kraken/cli/options/cache.py @@ -0,0 +1,21 @@ +from logging import getLogger + +from ...connection.cache import Cache + + +def clear_cache(): + """ + Deletes the cache. + :return: + """ + + Cache("main", getLogger("cache")).clear() + + +def clean_cache(): + """ + Deletes the outdated cache. (all expired cached files, and not indexed files) + :return: + """ + + Cache("main", getLogger("cache")).clean()