feat: clean and clear methods for the cache
This commit is contained in:
parent
2d4ba50b57
commit
fba9c31c50
@ -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)
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
21
src/music_kraken/cli/options/cache.py
Normal file
21
src/music_kraken/cli/options/cache.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user